aboutsummaryrefslogtreecommitdiff
path: root/server/src/Controller/Index.hs
diff options
context:
space:
mode:
authorJoris2017-11-19 00:20:25 +0100
committerJoris2017-11-19 00:20:25 +0100
commit7194cddb28656c721342c2ef604f9f9fb0692960 (patch)
tree5b8c8562c9a1680aa315b4b7e10a3a7c22900863 /server/src/Controller/Index.hs
parent42e94a45e26f40edc3ad71b1e77a4bf47c13fd3d (diff)
downloadbudget-7194cddb28656c721342c2ef604f9f9fb0692960.tar.gz
budget-7194cddb28656c721342c2ef604f9f9fb0692960.tar.bz2
budget-7194cddb28656c721342c2ef604f9f9fb0692960.zip
Show payment count and partition
- Also fixes exceedingPayer in back by using only punctual payments
Diffstat (limited to 'server/src/Controller/Index.hs')
-rw-r--r--server/src/Controller/Index.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/server/src/Controller/Index.hs b/server/src/Controller/Index.hs
index bf4859d..f05ce6f 100644
--- a/server/src/Controller/Index.hs
+++ b/server/src/Controller/Index.hs
@@ -10,10 +10,9 @@ import Network.HTTP.Types.Status (ok200)
import Prelude hiding (error)
import Web.Scotty hiding (get)
-import qualified Common.Message as Message
-import Common.Message.Key (Key)
-import qualified Common.Message.Key as Key
import Common.Model (InitResult (..), User (..))
+import Common.Msg (Key)
+import qualified Common.Msg as Msg
import Conf (Conf (..))
import qualified LoginSession
@@ -31,7 +30,7 @@ get conf mbToken = do
userOrError <- validateSignIn conf token
case userOrError of
Left errorKey ->
- return . InitEmpty . Left . Message.get $ errorKey
+ return . InitEmpty . Left . Msg.get $ errorKey
Right user ->
liftIO . Query.run . fmap InitSuccess $ getInit user conf
Nothing -> do
@@ -54,23 +53,23 @@ validateSignIn conf textToken = do
now <- liftIO getCurrentTime
case mbSignIn of
Nothing ->
- return . Left $ Key.SignIn_LinkInvalid
+ return . Left $ Msg.SignIn_LinkInvalid
Just signIn ->
if SignIn.isUsed signIn
then
- return . Left $ Key.SignIn_LinkUsed
+ return . Left $ Msg.SignIn_LinkUsed
else
let diffTime = now `diffUTCTime` (SignIn.creation signIn)
in if diffTime > signInExpiration conf
then
- return . Left $ Key.SignIn_LinkExpired
+ return . Left $ Msg.SignIn_LinkExpired
else do
LoginSession.put conf (SignIn.token signIn)
mbUser <- liftIO . Query.run $ do
SignIn.signInTokenToUsed . SignIn.id $ signIn
User.get . SignIn.email $ signIn
return $ case mbUser of
- Nothing -> Left Key.Secure_Unauthorized
+ Nothing -> Left Msg.Secure_Unauthorized
Just user -> Right user
getLoggedUser :: ActionM (Maybe User)