Skip to content

Commit 8ab492b

Browse files
committed
fix: prevent admin being redirected
1 parent 35992b9 commit 8ab492b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

frontend/app/composables/useAuth.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,32 @@ export function useAuth() {
4343
// Only fetch user data if we have a token AND we're not on the callback page
4444
const { isAuthReady } = useAuthReady()
4545

46-
const { data } = useGetMeQuery({
46+
const { data, fetching } = useGetMeQuery({
4747
pause: computed(() => !isAuthReady.value),
4848
})
4949

50+
// If we already have user data, mark as not loading
51+
if (me.value) {
52+
isLoading.value = false
53+
}
54+
55+
// If we don't have a token, we're not loading (we're just not authenticated)
56+
if (!token.value) {
57+
isLoading.value = false
58+
}
59+
60+
// Update loading state: we're done loading when query is not fetching
61+
// This handles both completed queries and paused queries
62+
watch(
63+
fetching,
64+
(isFetching) => {
65+
if (!isFetching) {
66+
isLoading.value = false
67+
}
68+
},
69+
{ immediate: true },
70+
)
71+
5072
watch(
5173
() => data.value?.me,
5274
(newMe) => {

0 commit comments

Comments
 (0)