Permalink
Browse files

Update to latest heist API changes

  • Loading branch information...
1 parent ce65c1c commit 4bf44c1395d2e024b034cec46218c00393cc64f1 @mightybyte mightybyte committed Aug 22, 2013
Showing with 33 additions and 33 deletions.
  1. +33 −33 src/Snap/Snaplet/Auth/SpliceHelpers.hs
@@ -57,9 +57,9 @@ addAuthSplices
-> Initializer b v ()
addAuthSplices h auth = addConfig h $ mempty
{ hcInterpretedSplices = do
- "ifLoggedIn" ?! ifLoggedIn auth
- "ifLoggedOut" ?! ifLoggedOut auth
- "loggedInUser" ?! loggedInUser auth
+ "ifLoggedIn" ## ifLoggedIn auth
+ "ifLoggedOut" ## ifLoggedOut auth
+ "loggedInUser" ## loggedInUser auth
, hcCompiledSplices = compiledAuthSplices auth
}
@@ -70,50 +70,50 @@ addAuthSplices h auth = addConfig h $ mempty
compiledAuthSplices :: SnapletLens b (AuthManager b)
-> Splices (SnapletCSplice b)
compiledAuthSplices auth = do
- "ifLoggedIn" ?! cIfLoggedIn auth
- "ifLoggedOut" ?! cIfLoggedOut auth
- "loggedInUser" ?! cLoggedInUser auth
+ "ifLoggedIn" ## cIfLoggedIn auth
+ "ifLoggedOut" ## cIfLoggedOut auth
+ "loggedInUser" ## cLoggedInUser auth
------------------------------------------------------------------------------
-- | Function to generate interpreted splices from an AuthUser.
userISplices :: Monad m => AuthUser -> Splices (I.Splice m)
userISplices AuthUser{..} = do
- "userId" ?! I.textSplice $ maybe "-" unUid userId
- "userLogin" ?! I.textSplice userLogin
- "userEmail" ?! I.textSplice $ fromMaybe "-" userEmail
- "userActive" ?! I.textSplice $ T.pack $ show $ isNothing userSuspendedAt
- "userLoginCount" ?! I.textSplice $ T.pack $ show userLoginCount
- "userFailedCount" ?! I.textSplice $ T.pack $ show userFailedLoginCount
- "userLoginAt" ?! I.textSplice $ maybe "-" (T.pack . show) userCurrentLoginAt
- "userLastLoginAt" ?! I.textSplice $ maybe "-" (T.pack . show) userLastLoginAt
- "userSuspendedAt" ?! I.textSplice $ maybe "-" (T.pack . show) userSuspendedAt
- "userLoginIP" ?! I.textSplice $ maybe "-" decodeUtf8 userCurrentLoginIp
- "userLastLoginIP" ?! I.textSplice $ maybe "-" decodeUtf8 userLastLoginIp
- "userIfActive" ?! ifISplice $ isNothing userSuspendedAt
- "userIfSuspended" ?! ifISplice $ isJust userSuspendedAt
+ "userId" ## I.textSplice $ maybe "-" unUid userId
+ "userLogin" ## I.textSplice userLogin
+ "userEmail" ## I.textSplice $ fromMaybe "-" userEmail
+ "userActive" ## I.textSplice $ T.pack $ show $ isNothing userSuspendedAt
+ "userLoginCount" ## I.textSplice $ T.pack $ show userLoginCount
+ "userFailedCount" ## I.textSplice $ T.pack $ show userFailedLoginCount
+ "userLoginAt" ## I.textSplice $ maybe "-" (T.pack . show) userCurrentLoginAt
+ "userLastLoginAt" ## I.textSplice $ maybe "-" (T.pack . show) userLastLoginAt
+ "userSuspendedAt" ## I.textSplice $ maybe "-" (T.pack . show) userSuspendedAt
+ "userLoginIP" ## I.textSplice $ maybe "-" decodeUtf8 userCurrentLoginIp
+ "userLastLoginIP" ## I.textSplice $ maybe "-" decodeUtf8 userLastLoginIp
+ "userIfActive" ## ifISplice $ isNothing userSuspendedAt
+ "userIfSuspended" ## ifISplice $ isJust userSuspendedAt
------------------------------------------------------------------------------
-- | Compiled splices for AuthUser.
userCSplices :: Monad m => Splices (RuntimeSplice m AuthUser -> C.Splice m)
-userCSplices = unionWith const fields ifs
+userCSplices = fields `mappend` ifs
where
fields = mapS (C.pureSplice . C.textSplice) $ do
- "userId" ?! maybe "-" unUid . userId
- "userLogin" ?! userLogin
- "userEmail" ?! fromMaybe "-" . userEmail
- "userActive" ?! T.pack . show . isNothing . userSuspendedAt
- "userLoginCount" ?! T.pack . show . userLoginCount
- "userFailedCount" ?! T.pack . show . userFailedLoginCount
- "userLoginAt" ?! maybe "-" (T.pack . show) . userCurrentLoginAt
- "userLastLoginAt" ?! maybe "-" (T.pack . show) . userLastLoginAt
- "userSuspendedAt" ?! maybe "-" (T.pack . show) . userSuspendedAt
- "userLoginIP" ?! maybe "-" decodeUtf8 . userCurrentLoginIp
- "userLastLoginIP" ?! maybe "-" decodeUtf8 . userLastLoginIp
+ "userId" ## maybe "-" unUid . userId
+ "userLogin" ## userLogin
+ "userEmail" ## fromMaybe "-" . userEmail
+ "userActive" ## T.pack . show . isNothing . userSuspendedAt
+ "userLoginCount" ## T.pack . show . userLoginCount
+ "userFailedCount" ## T.pack . show . userFailedLoginCount
+ "userLoginAt" ## maybe "-" (T.pack . show) . userCurrentLoginAt
+ "userLastLoginAt" ## maybe "-" (T.pack . show) . userLastLoginAt
+ "userSuspendedAt" ## maybe "-" (T.pack . show) . userSuspendedAt
+ "userLoginIP" ## maybe "-" decodeUtf8 . userCurrentLoginIp
+ "userLastLoginIP" ## maybe "-" decodeUtf8 . userLastLoginIp
ifs = do
- "userIfActive" ?! ifCSplice (isNothing . userSuspendedAt)
- "userIfSuspended" ?! ifCSplice (isJust . userSuspendedAt)
+ "userIfActive" ## ifCSplice (isNothing . userSuspendedAt)
+ "userIfSuspended" ## ifCSplice (isJust . userSuspendedAt)
------------------------------------------------------------------------------

0 comments on commit 4bf44c1

Please sign in to comment.