You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user logs in, the user is redirected to home.
When the page is refreshed, the user will be logged in again, and because of that, redirected to home again.
I think that this is bad UX.
What does the proposed changes look like?
I want to disable redirect in case there was a refresh.
Maybe this can be enabled / disabled by adding an option to nuxt.config?
auth: {
refreshRedirect: false
}
Changing this in the watchState of the init function in /lib/core/auth.js should work:
// Watch for loggedIn changes only in client side
if (process.browser) {
this.$storage.watchState('loggedIn', loggedIn => {
if (!routeOption(this.ctx.route, 'auth', false)) {
//disable redirect after login on refresh / first load.
if(!this.options.refreshRedirect){
if(loggedIn && !this.ctx.from){
return
}
}
this.redirect(loggedIn ? 'home' : 'logout')
}
})
}
Not sure if this is the best way of implementing it, but it works for me.
Edit: Changed the implementation because my previous method didn't redirect on first load even when NOT logged in.
This feature request is available on Nuxt.js community (#c113)
The text was updated successfully, but these errors were encountered:
What problem does this feature solve?
When a user logs in, the user is redirected to
home
.When the page is refreshed, the user will be logged in again, and because of that, redirected to
home
again.I think that this is bad UX.
What does the proposed changes look like?
I want to disable redirect in case there was a
refresh
.Maybe this can be enabled / disabled by adding an option to nuxt.config?
Changing this in the watchState of the
init
function in/lib/core/auth.js
should work:Not sure if this is the best way of implementing it, but it works for me.
Edit:
Changed the implementation because my previous method didn't redirect on first load even when NOT logged in.
The text was updated successfully, but these errors were encountered: