Several fixes, improvements, refactor for authentication

This commit is contained in:
2024-12-27 19:00:53 +01:00
parent 9d0f810ab3
commit 18b07d2f46
20 changed files with 113 additions and 131 deletions

View File

@ -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' }