Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if user logged in on unprotected page when logging out to that page #1489

Closed
moshetanzer opened this issue Mar 14, 2024 · 5 comments
Closed
Labels
bug Something ain't right...

Comments

@moshetanzer
Copy link
Contributor

moshetanzer commented Mar 14, 2024

Package

lucia

Describe the bug

For the login page of my Nuxt 3 app if user is logged in I want to redirect the user to dashboard page automatically. You can't use authenticatedUser() on the login page since it is not a protected page, and when using user to do a simple test like this both in middleware or on login page itself when signing out - it stays on dashboard page until complete refresh?

Thanks for the lib and goold luck with uni

//login.vue
const user = useUser();
if (user.value) {
  navigateTo("/dashboard");
}
@moshetanzer moshetanzer added the bug Something ain't right... label Mar 14, 2024
@moshetanzer moshetanzer changed the title [Bug]: Check if user logged in on unprotected page when logging out to that page Mar 14, 2024
@pilcrowOnPaper
Copy link
Member

Sounds like a Nuxt question? I don't use Nuxt so I don't think I help much either

@moshetanzer
Copy link
Contributor Author

@pilcrowOnPaper, nope - it is a lucia question. Why is user.value still true after logging out before completion of redirect to login page...

@pilcrowOnPaper
Copy link
Member

Because there's nothing updating the value of user.value? Just set the value to null after making a fetch request if you need it before the redirect

@moshetanzer
Copy link
Contributor Author

moshetanzer commented Mar 14, 2024 via email

@pilcrowOnPaper
Copy link
Member

pilcrowOnPaper commented Mar 14, 2024

When you redirect, the middleware for the destination page runs which fetches the latest user data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something ain't right...
Projects
None yet
Development

No branches or pull requests

2 participants