defaultDest -> loginDest, logoutDest

This commit is contained in:
Michael Snoyman 2010-10-05 09:26:05 +02:00
parent 9ba28dc72e
commit 3342dd5db9
3 changed files with 11 additions and 6 deletions

View File

@ -47,9 +47,13 @@ data Creds m = Creds
class Yesod m => YesodAuth m where
type AuthId m
-- | Default destination on successful login or logout, if no other
-- | Default destination on successful login, if no other
-- destination exists.
defaultDest :: m -> Route m
loginDest :: m -> Route m
-- | Default destination on successful logout, if no other
-- destination exists.
logoutDest :: m -> Route m
getAuthId :: Creds m -> GHandler s m (Maybe (AuthId m))
@ -93,7 +97,7 @@ setCreds doRedirects creds = do
if doRedirects
then do
setMessage $ string "You are now logged in"
redirect RedirectTemporary $ defaultDest y
redirect RedirectTemporary $ loginDest y
else return ()
getCheckR :: YesodAuth m => GHandler Auth m RepHtmlJson
@ -128,7 +132,7 @@ postLogoutR :: YesodAuth m => GHandler Auth m ()
postLogoutR = do
y <- getYesod
deleteSession credsKey
redirectUltDest RedirectTemporary $ defaultDest y
redirectUltDest RedirectTemporary $ logoutDest y
handlePluginR :: YesodAuth m => String -> [String] -> GHandler Auth m ()
handlePluginR plugin pieces = do

View File

@ -228,7 +228,7 @@ postPasswordR = do
setPassword aid salted
setMessage $ string "Password updated"
y <- getYesod
redirect RedirectTemporary $ defaultDest y
redirect RedirectTemporary $ loginDest y
saltLength :: Int
saltLength = 5

View File

@ -29,7 +29,8 @@ mkYesod "A2" [$parseRoutes|
instance Yesod A2 where approot _ = "http://localhost:3000"
instance YesodAuth A2 where
type AuthId A2 = String
defaultDest _ = AuthR CheckR
loginDest _ = AuthR CheckR
logoutDest _ = AuthR CheckR
getAuthId = return . Just . credsIdent
showAuthId = const id
readAuthId = const Just