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

Automatic redirect to logout on login #1788

Open
cblp opened this issue Nov 5, 2022 · 3 comments
Open

Automatic redirect to logout on login #1788

cblp opened this issue Nov 5, 2022 · 3 comments

Comments

@cblp
Copy link
Contributor

cblp commented Nov 5, 2022

I haven't figured out yet how exactly this happens, but sometimes my website remembers I am on the LogoutR page, and after successful login redirects me to the LogoutR, so I see message You successfully logged in but I'm logged out.

I think, it may be useful to skip LogoutR when trying to save ultimate destination, or when it is read. I can write a pull request, just give me a hint what is the proper solution.

@jezen
Copy link
Member

jezen commented Nov 6, 2022

You could do something like this:

instance YesodAuth App where
 
  onLogin = do
    lookupSession "_ULT" >>= \case
      Just url -> case parseRoute (toSegmentsAndQuery (encodeUtf8 url)) of
        Just LogoutR -> clearUltDest
        _ -> pure ()
      Nothing -> pure ()

@schoettl
Copy link
Contributor

schoettl commented Nov 6, 2022

I'm looking at the yesod-scaffold repo (branch postgres). Wouldn't that patch be a nice one for Foundation.hs?
Another possibility might be to implement redirectToReferer and return False if the destination is the logout route. But I'm not sure if the "referer" only refers to the Referer HTTP Header or also to the destination...

@cblp
Copy link
Contributor Author

cblp commented Nov 6, 2022

@jezen, it doesn't look like a systematic solution. Yesod already knows what LogoutR is https://github.com/yesodweb/yesod/blob/master/yesod-auth/Yesod/Auth/Routes.hs and defines its behaviour.

cblp added a commit to montelibero-org/veche that referenced this issue Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants