packages feed

yesod-auth 1.1.1.7 → 1.1.2

raw patch · 2 files changed

+27/−13 lines, 2 files

Files

Yesod/Auth.hs view
@@ -19,7 +19,7 @@     , Creds (..)     , setCreds       -- * User functions-    , maybeAuthId+    , defaultMaybeAuthId     , maybeAuth     , requireAuthId     , requireAuth@@ -126,6 +126,31 @@     onLogout :: GHandler s m ()     onLogout = return () +    -- | Retrieves user credentials, if user is authenticated.+    --+    -- By default, this calls 'defaultMaybeAuthId' to get the user ID from the+    -- session. This can be overridden to allow authentication via other means,+    -- such as checking for a special token in a request header. This is+    -- especially useful for creating an API to be accessed via some means+    -- other than a browser.+    --+    -- Since 1.1.2+    maybeAuthId :: GHandler s m (Maybe (AuthId m))+    maybeAuthId = defaultMaybeAuthId++credsKey :: Text+credsKey = "_ID"++-- | Retrieves user credentials from the session, if user is authenticated.+--+-- Since 1.1.2+defaultMaybeAuthId :: YesodAuth m => GHandler s m (Maybe (AuthId m))+defaultMaybeAuthId = do+    ms <- lookupSession credsKey+    case ms of+        Nothing -> return Nothing+        Just s -> return $ fromPathPiece s+ mkYesodSub "Auth"     [ ClassP ''YesodAuth [VarT $ mkName "master"]     ]@@ -137,9 +162,6 @@ /page/#Text/STRINGS PluginR |] -credsKey :: Text-credsKey = "_ID"- -- | FIXME: won't show up till redirect setCreds :: YesodAuth m => Bool -> Creds m -> GHandler s m () setCreds doRedirects creds = do@@ -209,14 +231,6 @@     case filter (\x -> apName x == plugin) (authPlugins master) of         [] -> notFound         ap:_ -> apDispatch ap method pieces---- | Retrieves user credentials, if user is authenticated.-maybeAuthId :: YesodAuth m => GHandler s m (Maybe (AuthId m))-maybeAuthId = do-    ms <- lookupSession credsKey-    case ms of-        Nothing -> return Nothing-        Just s -> return $ fromPathPiece s  maybeAuth :: ( YesodAuth m              , b ~ YesodPersistBackend m
yesod-auth.cabal view
@@ -1,5 +1,5 @@ name:            yesod-auth-version:         1.1.1.7+version:         1.1.2 license:         MIT license-file:    LICENSE author:          Michael Snoyman, Patrick Brisbin