Advertisement
m1dnight

Untitled

Jan 8th, 2014
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. withLoggedInUser :: (Db.User -> H ()) -> H ()
  2. withLoggedInUser action =
  3. with auth currentUser >>= go
  4. where
  5. go Nothing =
  6. with auth $ handleLoginGet (Just "You are currently not logged in. Thou shall not pass.")
  7. go (Just user) = logRunEitherT $ do
  8. uid <- tryJust "withLoggedInUser: missing uid" (userId user)
  9. uid' <- hoistEither (reader T.decimal (unUid uid))
  10. return $ action (Db.User uid' (userLogin user))
  11. Funcites oproepen gebeurt dan zo:
  12.  
  13. , ("/new_user", with auth handleNewUser)
  14. , ("/events", handleViewAllEvents)
  15.  
  16. handleViewAllEvents :: H()
  17. handleViewAllEvents = method GET (withLoggedInUser (viewEventList Nothing))
  18.  
  19. viewEventList :: Maybe T.Text -> Db.User -> H()
  20. viewEventList err _ =
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement