-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Hi!
I have the following structure:
- a login page
- a dashboard page (for signed in users)
- an auth middleware (not global, and both pages are using it via the
definePageMeta)
What's happening:
- I log in using the
signInWithPassword. I await that call, and after it is completed and without errors I redirect the user to the dashboard page. - The auth middleware was triggered, allowed the passage to the dashboard page since for the middleware the session (from
useSupabaseSession) is valid (as expected). - The dashboard page loads. I then have this (more or less, this is a reduced example):
<script setup lang="ts">
const user = useSupabaseUser()
onMounted(async () => {
if (!user.value || !user.value.email) {
console.error("no user!")
}
})
</script>
Problem:
The user is not defined during the onMounted and I don't get why. If I reload the page, it works. If I await a bit before redirecting the page, it also works, but that seems rather inelegant.
Thank you for the help!
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested