Merge pull request #1461 from LiveViewTech/redirect_to_current

Redirect to current
This commit is contained in:
Michael Snoyman 2017-12-08 09:02:59 +02:00 committed by GitHub
commit c122af25ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,7 @@
## 1.4.21
* Add redirectToCurrent to Yesod.Auth module for controlling setUltDestCurrent in redirectLogin [#1461](https://github.com/yesodweb/yesod/pull/1461)
## 1.4.20
* Extend `YesodAuthEmail` to support extensible password hashing via

View File

@ -166,7 +166,7 @@ class (Yesod master, PathPiece (AuthId master), RenderMessage master FormMessage
-- > when (isJust ma) $
-- > lift $ redirect HomeR -- or any other Handler code you want
-- > defaultLoginHandler
--
--
loginHandler :: HandlerT Auth (HandlerT master IO) Html
loginHandler = defaultLoginHandler
@ -182,6 +182,12 @@ class (Yesod master, PathPiece (AuthId master), RenderMessage master FormMessage
redirectToReferer :: master -> Bool
redirectToReferer _ = False
-- | When being redirected to the login page should the current page
-- be set to redirect back to. Default is 'True'.
-- @since 1.4.18
redirectToCurrent :: master -> Bool
redirectToCurrent _ = True
-- | Return an HTTP connection manager that is stored in the foundation
-- type. This allows backends to reuse persistent connections. If none of
-- the backends you're using use HTTP connections, you can safely return
@ -551,15 +557,15 @@ requireAuthPair :: (YesodAuthPersist master, Typeable (AuthEntity master))
=> HandlerT master IO (AuthId master, AuthEntity master)
requireAuthPair = maybeAuthPair >>= maybe handleAuthLack return
handleAuthLack :: Yesod master => HandlerT master IO a
handleAuthLack :: YesodAuth master => HandlerT master IO a
handleAuthLack = do
aj <- acceptsJson
if aj then notAuthenticated else redirectLogin
redirectLogin :: Yesod master => HandlerT master IO a
redirectLogin :: YesodAuth master => HandlerT master IO a
redirectLogin = do
y <- getYesod
setUltDestCurrent
when (redirectToCurrent y) setUltDestCurrent
case authRoute y of
Just z -> redirect z
Nothing -> permissionDenied "Please configure authRoute"

View File

@ -1,5 +1,5 @@
name: yesod-auth
version: 1.4.20
version: 1.4.21
license: MIT
license-file: LICENSE
author: Michael Snoyman, Patrick Brisbin