Skip to content

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

Open
@chachew

Description

@chachew

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions