clearCreds redirect behavior depends on request type.
This commit is contained in:
parent
006fa6cb9e
commit
ceeeb16ae0
@ -1,5 +1,9 @@
|
|||||||
# ChangeLog for yesod-auth
|
# ChangeLog for yesod-auth
|
||||||
|
|
||||||
|
## 1.6.7
|
||||||
|
|
||||||
|
* Redirect behavior of `clearCreds` depends on request type [#1598](https://github.com/yesodweb/yesod/pull/1598)
|
||||||
|
|
||||||
## 1.6.6
|
## 1.6.6
|
||||||
|
|
||||||
* Deprecated `Yesod.Auth.GoogleEmail2`, see [#1579](https://github.com/yesodweb/yesod/issues/1579) and [migration blog post](https://pbrisbin.com/posts/googleemail2_deprecation/)
|
* Deprecated `Yesod.Auth.GoogleEmail2`, see [#1579](https://github.com/yesodweb/yesod/issues/1579) and [migration blog post](https://pbrisbin.com/posts/googleemail2_deprecation/)
|
||||||
|
|||||||
@ -421,14 +421,20 @@ authLayoutJson w json = selectRep $ do
|
|||||||
--
|
--
|
||||||
-- @since 1.1.7
|
-- @since 1.1.7
|
||||||
clearCreds :: (MonadHandler m, YesodAuth (HandlerSite m))
|
clearCreds :: (MonadHandler m, YesodAuth (HandlerSite m))
|
||||||
=> Bool -- ^ if HTTP redirect to 'logoutDest' should be done
|
=> Bool -- ^ if HTTP, redirect to 'logoutDest'
|
||||||
-> m ()
|
-> m ()
|
||||||
clearCreds doRedirects = do
|
clearCreds doRedirects = do
|
||||||
y <- getYesod
|
|
||||||
onLogout
|
onLogout
|
||||||
deleteSession credsKey
|
deleteSession credsKey
|
||||||
when doRedirects $ do
|
y <- getYesod
|
||||||
redirectUltDest $ logoutDest y
|
aj <- acceptsJson
|
||||||
|
case (aj, doRedirects) of
|
||||||
|
(True, _) -> sendResponse successfulLogout
|
||||||
|
(False, True) -> redirectUltDest (logoutDest y)
|
||||||
|
_ -> return ()
|
||||||
|
where successfulLogout = object ["message" .= msg]
|
||||||
|
msg :: Text
|
||||||
|
msg = "Logged out successfully!"
|
||||||
|
|
||||||
getCheckR :: AuthHandler master TypedContent
|
getCheckR :: AuthHandler master TypedContent
|
||||||
getCheckR = do
|
getCheckR = do
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-auth
|
name: yesod-auth
|
||||||
version: 1.6.6
|
version: 1.6.7
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman, Patrick Brisbin
|
author: Michael Snoyman, Patrick Brisbin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user