happstack-auth 0.2.1 → 0.2.1.1
raw patch · 2 files changed
+23/−1 lines, 2 files
Files
- happstack-auth.cabal +1/−1
- src/Happstack/Auth.hs +22/−0
happstack-auth.cabal view
@@ -1,5 +1,5 @@ Name: happstack-auth-Version: 0.2.1+Version: 0.2.1.1 License: BSD3 License-File: LICENSE Author: Nils Schweinsberg
src/Happstack/Auth.hs view
@@ -91,7 +91,9 @@ ) where +#if MIN_VERSION_happstack(0,5,1) import Control.Applicative+#endif import Control.Monad.Reader import Data.Maybe import System.Time@@ -332,14 +334,26 @@ dat <- getDataFn $ do #endif un <- look $ fromMaybe "username" muname+#if MIN_VERSION_happstack(0,5,1) pw <- optional . look $ fromMaybe "password" mpwd+#else+ pw <- (Just `fmap` (look $ fromMaybe "password" mpwd)) `mplus` return Nothing+#endif return (un,pw) case dat of+#if MIN_VERSION_happstack(0,5,1) Right (u, Just p) -> authUser u p+#else+ Just (u, Just p) -> authUser u p+#endif >>= maybe (failR (Just u) (Just p)) (\user -> performLogin mins user okR)+#if MIN_VERSION_happstack(0,5,1) Right (u, mp) -> failR (Just u) mp+#else+ Just (u, mp) -> failR (Just u) mp+#endif _ -> failR Nothing Nothing @@ -395,10 +409,18 @@ -> m r withSessionId f = do clearExpiredSessions+#if MIN_VERSION_happstack(0,5,1) withDataFn queryPolicy getSessionId f+#else+ withDataFn getSessionId f+#endif where getSessionId :: (Read a) => RqData (Maybe a)+#if MIN_VERSION_happstack(0,5,1) getSessionId = optional $ readCookieValue sessionCookie+#else+ getSessionId = (Just `fmap` readCookieValue sessionCookie) `mplus` return Nothing+#endif -- | Run a `ServerPartT' with the `SessionData' of the currently logged in user