diff options
author | Joris | 2015-08-29 13:30:09 +0200 |
---|---|---|
committer | Joris | 2015-08-29 13:30:09 +0200 |
commit | 6b466f616035c2fc03359d182c074f096d6b7f17 (patch) | |
tree | 47708f2e96614d71059f98c757d6a3fe88c8b923 /src/server/Controller | |
parent | aa7f70d172be9ef322f9a0d19d1d9d9489f9fa75 (diff) |
Showing exceeding payers
Diffstat (limited to 'src/server/Controller')
-rw-r--r-- | src/server/Controller/Payment.hs | 7 | ||||
-rw-r--r-- | src/server/Controller/SignIn.hs | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/server/Controller/Payment.hs b/src/server/Controller/Payment.hs index cbd342a..117310a 100644 --- a/src/server/Controller/Payment.hs +++ b/src/server/Controller/Payment.hs @@ -2,6 +2,7 @@ module Controller.Payment ( getPaymentsAction , createPaymentAction , deletePaymentAction + , getTotalPaymentsAction ) where import Web.Scotty @@ -47,3 +48,9 @@ deletePaymentAction paymentId = status badRequest400 json . Message . getMessage $ PaymentNotDeleted ) + +getTotalPaymentsAction :: ActionM () +getTotalPaymentsAction = + Secure.loggedAction (\_ -> do + (liftIO . runDb $ getTotalPayments) >>= json + ) diff --git a/src/server/Controller/SignIn.hs b/src/server/Controller/SignIn.hs index 80885bf..40cf474 100644 --- a/src/server/Controller/SignIn.hs +++ b/src/server/Controller/SignIn.hs @@ -61,8 +61,8 @@ errorResponse msg = do status badRequest400 json (Message msg) -validateSignInAction :: Text -> ActionM () -validateSignInAction token = do +validateSignInAction :: Config -> Text -> ActionM () +validateSignInAction config token = do maybeSignIn <- liftIO . runDb $ getSignInToken token now <- liftIO getCurrentTime case maybeSignIn of @@ -72,7 +72,7 @@ validateSignInAction token = do redirectError (getMessage SignInUsed) else let diffTime = now `diffUTCTime` (signInCreation . entityVal $ signIn) - in if diffTime > 2 * 60 -- 2 minutes + in if diffTime > (fromIntegral $ (signInExpirationMn config) * 60) then redirectError (getMessage SignInExpired) else do |