diff options
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 |