diff options
author | Joris Guyonvarch | 2015-07-20 21:55:52 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-07-20 21:55:52 +0200 |
commit | a271d6034bc4cc631a64476d25d21c83a701fa39 (patch) | |
tree | 89ffa3df69999c5c9ed3cda9f4e4ec04f7a6ae1d /src/server/Application.hs | |
parent | a40c4825996c90d107901b0d71162f9356f1395a (diff) | |
download | budget-a271d6034bc4cc631a64476d25d21c83a701fa39.tar.gz budget-a271d6034bc4cc631a64476d25d21c83a701fa39.tar.bz2 budget-a271d6034bc4cc631a64476d25d21c83a701fa39.zip |
Add a payment from the UI, it needs polishing however
Diffstat (limited to 'src/server/Application.hs')
-rw-r--r-- | src/server/Application.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/server/Application.hs b/src/server/Application.hs index 7e93fe1..24342dc 100644 --- a/src/server/Application.hs +++ b/src/server/Application.hs @@ -69,16 +69,18 @@ deleteUserAction email = do _ <- liftIO . runDb $ deleteUser email status ok200 -createPaymentAction :: Text -> Text -> Int -> ActionM () -createPaymentAction email name cost = do - maybeUser <- liftIO . runDb $ getUser email - case maybeUser of - Just user -> do - _ <- liftIO . runDb $ createPayment (entityKey user) name cost - return () - Nothing -> do - status badRequest400 - status ok200 +createPaymentAction :: Text -> Int -> ActionM () +createPaymentAction name cost = + Secure.loggedAction (\login -> do + maybeUser <- liftIO . runDb $ getUser login + case maybeUser of + Just user -> do + _ <- liftIO . runDb $ createPayment (entityKey user) name cost + return () + Nothing -> do + status badRequest400 + status ok200 + ) signInAction :: Text -> ActionM () signInAction login = |