Closed nfunwigabga closed 2 years ago
update to the latest version and try
This is fixed in the latest version. However, it seems to have introduced another minor issue... the user is not redirected away from the the login screen after login, even when watchLoggedIn: true
is set in the configuration.
I can't reproduce this issue on my end.
Hmm. weird. I just installed everything on a fresh project and got the same result. No redirect after login. I have to manually do navigateTo("/")
.
Here is how I set up the fresh install. Maybe I am missing something in the setup then? https://github.com/nfunwigabga/nuxt-auth-test
Everything else seems to be ok, including middleware etc.
I suggest just manually redirecting after login then. This is low priority for me at the moment.
Yep, that's what I'm doing. And yes it's low priority really.
For anyone looking, you may want to redirect the user the the intended
URL stored int he cookies on login. So this is what I'm doing:
const redirectUrl = useCookie('auth.redirect', { default: () => "/"})
const {$auth}=useNuxtApp()
async function login(){
try {
await $auth.loginWith("local", {
body: {email: "foo@bar.com", password: "password" },
});
navigateTo(redirectUrl.value);
redirectUrl.value = null; // clear the cookie on successful login
} catch (error) {
errors.value = error.data?.errors;
}
}
Cheers!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Whenever I try to fetch the current user, the user is fetched successfully but there is always a redirect to the homepage.
try:
Regardless of which page I am on, I get redirected to the home page after I get the response.
Using