hooked up all items on the list settings section

This commit is contained in:
Edward Tirado Jr 2026-04-05 00:36:20 -05:00
parent 53df349d9f
commit 91173021b2
32 changed files with 578 additions and 178 deletions

View file

@ -10,10 +10,54 @@ export const useAuth = () => {
await navigateTo('/')
}
const logout = async () => {
await $api('/api/logout', {method: 'POST'})
const register = async (email: string, username: string) => {
await $fetch('/sanctum/csrf-cookie', {
baseURL: config.public.apiBase,
credentials: 'include',
})
await $api('/api/register', {method: 'POST', body: {email, username}})
await navigateTo('/auth/login')
}
return {login, logout}
const resetPassword = async (password: string, passwordConfirmation: string, token: string, email: string) => {
await $fetch('/sanctum/csrf-cookie', {
baseURL: config.public.apiBase,
credentials: 'include',
})
await $api('/api/reset-password', {
method: 'POST',
body: {
password,
password_confirmation: passwordConfirmation,
token,
email
},
onResponseError: (context) => {
if (context.response.status === 401) {
throw new Error('TOKEN_EXPIRED')
}
}
})
await navigateTo('/lists')
}
const xsrfToken = useCookie('XSRF-TOKEN')
const logout = async () => {
await $fetch('/api/logout', {
baseURL: config.public.apiBase,
method: 'POST',
credentials: 'include',
headers: {
...(xsrfToken.value ? {'X-XSRF-TOKEN': xsrfToken.value} : {}),
},
}).catch(() => {
alert("Failed to logout. Please try again.")
})
useCookie('XSRF-TOKEN').value = ''
navigateTo('/auth/login')
}
return {login, register, resetPassword, logout}
}