Skip to content
This repository
Browse code

Update to latest heist API changes

  • Loading branch information...
commit 4bf44c1395d2e024b034cec46218c00393cc64f1 1 parent ce65c1c
Doug Beardsley authored August 22, 2013

Showing 1 changed file with 33 additions and 33 deletions. Show diff stats Hide diff stats

  1. 66  src/Snap/Snaplet/Auth/SpliceHelpers.hs
66  src/Snap/Snaplet/Auth/SpliceHelpers.hs
@@ -57,9 +57,9 @@ addAuthSplices
57 57
   -> Initializer b v ()
58 58
 addAuthSplices h auth = addConfig h $ mempty
59 59
     { hcInterpretedSplices = do
60  
-          "ifLoggedIn"   ?! ifLoggedIn auth
61  
-          "ifLoggedOut"  ?! ifLoggedOut auth
62  
-          "loggedInUser" ?! loggedInUser auth
  60
+          "ifLoggedIn"   ## ifLoggedIn auth
  61
+          "ifLoggedOut"  ## ifLoggedOut auth
  62
+          "loggedInUser" ## loggedInUser auth
63 63
     , hcCompiledSplices = compiledAuthSplices auth
64 64
     }
65 65
 
@@ -70,50 +70,50 @@ addAuthSplices h auth = addConfig h $ mempty
70 70
 compiledAuthSplices :: SnapletLens b (AuthManager b)
71 71
                     -> Splices (SnapletCSplice b)
72 72
 compiledAuthSplices auth = do
73  
-    "ifLoggedIn"   ?! cIfLoggedIn auth
74  
-    "ifLoggedOut"  ?! cIfLoggedOut auth
75  
-    "loggedInUser" ?! cLoggedInUser auth
  73
+    "ifLoggedIn"   ## cIfLoggedIn auth
  74
+    "ifLoggedOut"  ## cIfLoggedOut auth
  75
+    "loggedInUser" ## cLoggedInUser auth
76 76
 
77 77
 
78 78
 ------------------------------------------------------------------------------
79 79
 -- | Function to generate interpreted splices from an AuthUser.
80 80
 userISplices :: Monad m => AuthUser -> Splices (I.Splice m)
81 81
 userISplices AuthUser{..} = do
82  
-    "userId"          ?! I.textSplice $ maybe "-" unUid userId
83  
-    "userLogin"       ?! I.textSplice userLogin
84  
-    "userEmail"       ?! I.textSplice $ fromMaybe "-" userEmail
85  
-    "userActive"      ?! I.textSplice $ T.pack $ show $ isNothing userSuspendedAt
86  
-    "userLoginCount"  ?! I.textSplice $ T.pack $ show userLoginCount
87  
-    "userFailedCount" ?! I.textSplice $ T.pack $ show userFailedLoginCount
88  
-    "userLoginAt"     ?! I.textSplice $ maybe "-" (T.pack . show) userCurrentLoginAt
89  
-    "userLastLoginAt" ?! I.textSplice $ maybe "-" (T.pack . show) userLastLoginAt
90  
-    "userSuspendedAt" ?! I.textSplice $ maybe "-" (T.pack . show) userSuspendedAt
91  
-    "userLoginIP"     ?! I.textSplice $ maybe "-" decodeUtf8 userCurrentLoginIp
92  
-    "userLastLoginIP" ?! I.textSplice $ maybe "-" decodeUtf8 userLastLoginIp
93  
-    "userIfActive"    ?! ifISplice $ isNothing userSuspendedAt
94  
-    "userIfSuspended" ?! ifISplice $ isJust userSuspendedAt
  82
+    "userId"          ## I.textSplice $ maybe "-" unUid userId
  83
+    "userLogin"       ## I.textSplice userLogin
  84
+    "userEmail"       ## I.textSplice $ fromMaybe "-" userEmail
  85
+    "userActive"      ## I.textSplice $ T.pack $ show $ isNothing userSuspendedAt
  86
+    "userLoginCount"  ## I.textSplice $ T.pack $ show userLoginCount
  87
+    "userFailedCount" ## I.textSplice $ T.pack $ show userFailedLoginCount
  88
+    "userLoginAt"     ## I.textSplice $ maybe "-" (T.pack . show) userCurrentLoginAt
  89
+    "userLastLoginAt" ## I.textSplice $ maybe "-" (T.pack . show) userLastLoginAt
  90
+    "userSuspendedAt" ## I.textSplice $ maybe "-" (T.pack . show) userSuspendedAt
  91
+    "userLoginIP"     ## I.textSplice $ maybe "-" decodeUtf8 userCurrentLoginIp
  92
+    "userLastLoginIP" ## I.textSplice $ maybe "-" decodeUtf8 userLastLoginIp
  93
+    "userIfActive"    ## ifISplice $ isNothing userSuspendedAt
  94
+    "userIfSuspended" ## ifISplice $ isJust userSuspendedAt
95 95
 
96 96
 
97 97
 ------------------------------------------------------------------------------
98 98
 -- | Compiled splices for AuthUser.
99 99
 userCSplices :: Monad m => Splices (RuntimeSplice m AuthUser -> C.Splice m)
100  
-userCSplices = unionWith const fields ifs
  100
+userCSplices = fields `mappend` ifs
101 101
   where
102 102
     fields = mapS (C.pureSplice . C.textSplice) $ do
103  
-        "userId"          ?! maybe "-" unUid . userId
104  
-        "userLogin"       ?! userLogin
105  
-        "userEmail"       ?! fromMaybe "-" . userEmail
106  
-        "userActive"      ?! T.pack . show . isNothing . userSuspendedAt
107  
-        "userLoginCount"  ?! T.pack . show . userLoginCount
108  
-        "userFailedCount" ?! T.pack . show . userFailedLoginCount
109  
-        "userLoginAt"     ?! maybe "-" (T.pack . show) . userCurrentLoginAt
110  
-        "userLastLoginAt" ?! maybe "-" (T.pack . show) . userLastLoginAt
111  
-        "userSuspendedAt" ?! maybe "-" (T.pack . show) . userSuspendedAt
112  
-        "userLoginIP"     ?! maybe "-" decodeUtf8 . userCurrentLoginIp
113  
-        "userLastLoginIP" ?! maybe "-" decodeUtf8 . userLastLoginIp
  103
+        "userId"          ## maybe "-" unUid . userId
  104
+        "userLogin"       ## userLogin
  105
+        "userEmail"       ## fromMaybe "-" . userEmail
  106
+        "userActive"      ## T.pack . show . isNothing . userSuspendedAt
  107
+        "userLoginCount"  ## T.pack . show . userLoginCount
  108
+        "userFailedCount" ## T.pack . show . userFailedLoginCount
  109
+        "userLoginAt"     ## maybe "-" (T.pack . show) . userCurrentLoginAt
  110
+        "userLastLoginAt" ## maybe "-" (T.pack . show) . userLastLoginAt
  111
+        "userSuspendedAt" ## maybe "-" (T.pack . show) . userSuspendedAt
  112
+        "userLoginIP"     ## maybe "-" decodeUtf8 . userCurrentLoginIp
  113
+        "userLastLoginIP" ## maybe "-" decodeUtf8 . userLastLoginIp
114 114
     ifs = do
115  
-        "userIfActive"    ?! ifCSplice (isNothing . userSuspendedAt)
116  
-        "userIfSuspended" ?! ifCSplice (isJust . userSuspendedAt)
  115
+        "userIfActive"    ## ifCSplice (isNothing . userSuspendedAt)
  116
+        "userIfSuspended" ## ifCSplice (isJust . userSuspendedAt)
117 117
 
118 118
 
119 119
 ------------------------------------------------------------------------------

0 notes on commit 4bf44c1

Please sign in to comment.
Something went wrong with that request. Please try again.