Auth-module: auth middleware not working on logout when / is guarded

Created on 4 Feb 2018  路  8Comments  路  Source: nuxt-community/auth-module

After i call logout, loggedIn Watcher automatically redirects me to {home: /} but home is guarded by the middleware and should redirect to "/login" but it doesn't
the bug is as follows:

when it doesn't work:

  • i am logged in and at "/"
  • i logout
  • page redirects to "/" which is the same page so the middleware doesn't get called i guess?

when it does:

  • if i am logged in and at "/about"
  • i logout
  • i get redirected to "/login" (redirected to "/" and then automatically to "/login")

This question is available on Nuxt.js community (#c39)
discussion

Most helpful comment

Logout redirect option is available with 4.0.0 :)

All 8 comments

If home is guarded what i suggest (and personally use) is:

{
 redirect: {
  home: '/login'
 }
}

This makes sense because the home of auth is /login page in such project.

Now logout from / works
but since home is used for both successful login and successful logout, after a log in i remain on the same login page

its true that in such a project /login is home but once logged in the user should be redirected to another page which will act as his new home

Anyway if this how it is supposed to work then i will find some other way to get both login and logout to work the way i intend them to be

Hmm, you are right. Maybe we can keep this issue open until deciding on a better solution. 馃

@pi0 This seems to be confusing for many users, we should discuss this asap 馃憤

ref. #55

Hi, I have kind of the same issue here, because the home is use as a login and logout destination. When the user logs out, he stays on a page that he shouldn't have access.

I think the redirect options can be restructured like this.

redirect: {
  home: "/my-dashboard",  //redirection after logged in
  login: "/login",        //redirection if user is not logged in
  logout: "/",            //redirection after user has logged out
}

What do you think?
Thanks 馃檪

@igalil Having a separate logout redirect option idea is great and actually implemented in #61 ;)

@pi0, Oops I didn't search hard enough, sorry. I'll go ready the #61. Thanks a lot 馃檪

edit: Do you have an approximate idea of when the pull request will be merged? Thank you so much.

Logout redirect option is available with 4.0.0 :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manniL picture manniL  路  4Comments

ishitatsuyuki picture ishitatsuyuki  路  4Comments

DiegoGallegos4 picture DiegoGallegos4  路  3Comments

amjadkhan896 picture amjadkhan896  路  3Comments

roosht3 picture roosht3  路  3Comments