Several fixes, improvements, refactor for authentication
This commit is contained in:
@ -6,8 +6,10 @@ import { getDomain } from '@/application/utilities'
|
||||
export async function register(username: string, email: string, password: string) {
|
||||
try {
|
||||
const response = await axios.post(`${config.server_endpoint}/register`, { username, email, password })
|
||||
useCookies().set('token', response.data.data.token as string)
|
||||
return { success: true, token: response.data.data.token }
|
||||
if (response.status === 200) {
|
||||
return { success: true }
|
||||
}
|
||||
return { error: response.data.message }
|
||||
} catch (error: any) {
|
||||
if (typeof error.response?.data === 'undefined') {
|
||||
return { error: 'Could not connect to server' }
|
||||
|
Reference in New Issue
Block a user