1
0
forked from noxious/client
This commit is contained in:
Dennis Postma 2024-07-10 22:49:22 +02:00
parent 4d58801897
commit 236b091216

View File

@ -16,7 +16,10 @@ export async function register(username: string, password: string, socketStore =
export async function login(username: string, password: string, socketStore = useSocketStore()) {
try {
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
useCookies().set('token', response.data.token as string)
useCookies().set('token', response.data.token as string, {
// for whole domain
domain: window.location.hostname.split('.').slice(-2).join('.'),
})
return { success: true, token: response.data.token }
} catch (error: any) {
return { error: error.response.data.message }