feat(admin): add categories and teams management page

This commit is contained in:
gabdevele
2026-06-15 12:48:18 +02:00 Unverified
parent 48f0f65dc1
commit 8bf6f29561
13 changed files with 354 additions and 52 deletions
+6 -5
View File
@@ -8,7 +8,6 @@ import type {
} from "~/types/api";
export const useAuth = () => {
const route = useRoute()
const nuxtApp = useNuxtApp()
const token = useCookie<string | null>('auth_token', {
@@ -33,7 +32,8 @@ export const useAuth = () => {
tokenState.value = newVal || null
})
const syncUser = async (redirectOnSuccess = false) => {
const syncUser = async (options: { redirectOnSuccess?: boolean; currentPath?: string } = {}) => {
const { redirectOnSuccess = false, currentPath } = options
const tokenVal = tokenState.value || token.value
if (!tokenVal || isSyncingUser.value) return
@@ -42,10 +42,11 @@ export const useAuth = () => {
const res = await fetchCurrentUser()
if (res.ok) {
user.value = res.user
const path = currentPath ?? useNuxtApp().$router.currentRoute.value.path
if (res.user.must_change_password && route.path !== '/auth/change-password') {
if (res.user.must_change_password && path !== '/auth/change-password') {
await nuxtApp.runWithContext(() => navigateTo('/auth/change-password'))
} else if (redirectOnSuccess && route.path.startsWith('/auth')) {
} else if (redirectOnSuccess && path.startsWith('/auth')) {
await nuxtApp.runWithContext(() => navigateTo('/dashboard'))
}
}
@@ -65,7 +66,7 @@ export const useAuth = () => {
const handleLoginSuccess = async (jwtToken: string) => {
token.value = jwtToken
tokenState.value = jwtToken
await syncUser(true)
await syncUser({ redirectOnSuccess: true })
}
const logout = () => {