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

Do not allow logged in users to access login page #339

Open
chachew opened this issue Mar 28, 2024 · 0 comments
Open

Do not allow logged in users to access login page #339

chachew opened this issue Mar 28, 2024 · 0 comments
Labels
question Further information is requested

Comments

@chachew
Copy link

chachew commented Mar 28, 2024

Is there an easy way to NOT allow logged in users to access the login/register pages? Once the user is logged in there should be no reason to access those pages, instead they should be redirected to the index page.('/')

Ive tried adding route redirects in the nuxt.config as well as adding a middleware to the login/register pages butt he page is accessed first for a few seconds before it gets redirected to the index page ('/').

loggedIn.ts middleware
export default defineNuxtRouteMiddleware(async (to, from) => { const user = useSupabaseUser(); if (user.value) return navigateTo('/'); });

This is not working as expected because it seems there is a few second delay on page load when user accesses the url directly and when the redirect(navigateTo) is fired.

@chachew chachew added the question Further information is requested label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant