fix registration availability checks and signup endpoint
- correct api paths for username/email availability checks - use singleton userAdapter instead of creating new instance - use getApiBaseUrl() for signup to include /api/v1 prefix
This commit is contained in:
parent
30128107fb
commit
7e0f66d9cc
3 changed files with 5 additions and 7 deletions
|
|
@ -197,7 +197,7 @@ export class UserAdapter extends BaseAdapter {
|
|||
* Check username availability
|
||||
*/
|
||||
async checkUsernameAvailability(username: string): Promise<{ available: boolean }> {
|
||||
return this.request<{ available: boolean }>(`/users/check-username`, {
|
||||
return this.request<{ available: boolean }>(`/check/username`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ username })
|
||||
})
|
||||
|
|
@ -207,7 +207,7 @@ export class UserAdapter extends BaseAdapter {
|
|||
* Check email availability
|
||||
*/
|
||||
async checkEmailAvailability(email: string): Promise<{ available: boolean }> {
|
||||
return this.request<{ available: boolean }>(`/users/check-email`, {
|
||||
return this.request<{ available: boolean }>(`/check/email`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email })
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import AuthCard from '$lib/components/auth/AuthCard.svelte'
|
||||
import Input from '$lib/components/ui/Input.svelte'
|
||||
import Button from '$lib/components/ui/Button.svelte'
|
||||
import { UserAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import { userAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import * as m from '$lib/paraglide/messages'
|
||||
|
||||
interface Props {
|
||||
|
|
@ -38,8 +38,6 @@
|
|||
let usernameTimer: ReturnType<typeof setTimeout>
|
||||
let emailTimer: ReturnType<typeof setTimeout>
|
||||
|
||||
const userAdapter = new UserAdapter()
|
||||
|
||||
// Username validation regex
|
||||
const usernameRegex = /^[a-zA-Z0-9_-]+$/
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { RequestHandler } from '@sveltejs/kit'
|
|||
import { json } from '@sveltejs/kit'
|
||||
import { dev } from '$app/environment'
|
||||
import { z } from 'zod'
|
||||
import { PUBLIC_SIERO_API_URL } from '$env/static/public'
|
||||
import { getApiBaseUrl } from '$lib/api/adapters/config'
|
||||
import { passwordGrantLogin } from '$lib/auth/oauth'
|
||||
import { userAdapter } from '$lib/api/adapters/user.adapter'
|
||||
import { buildCookies } from '$lib/auth/map'
|
||||
|
|
@ -40,7 +40,7 @@ export const POST: RequestHandler = async ({ request, cookies, fetch }) => {
|
|||
|
||||
try {
|
||||
// 1. Create user account via API
|
||||
const signupRes = await fetch(`${PUBLIC_SIERO_API_URL}/users`, {
|
||||
const signupRes = await fetch(`${getApiBaseUrl()}/users`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
|
|
|
|||
Loading…
Reference in a new issue