aboutsummaryrefslogtreecommitdiff
path: root/src/server/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Controller')
-rw-r--r--src/server/Controller/Index.hs8
-rw-r--r--src/server/Controller/Payment.hs1
-rw-r--r--src/server/Controller/SignIn.hs26
3 files changed, 17 insertions, 18 deletions
diff --git a/src/server/Controller/Index.hs b/src/server/Controller/Index.hs
index e4ec729..db1038a 100644
--- a/src/server/Controller/Index.hs
+++ b/src/server/Controller/Index.hs
@@ -7,15 +7,15 @@ import Web.Scotty
import Network.HTTP.Types.Status (ok200)
-import Config (Config(..))
+import Conf (Conf(..))
import qualified LoginSession
-import qualified Model.Json.Config as M
+import qualified Model.Json.Conf as M
import View.Page (page)
-getIndex :: Config -> ActionM ()
-getIndex config = html . page $ M.Config { M.currency = currency config }
+getIndex :: Conf -> ActionM ()
+getIndex conf = html . page $ M.Conf { M.currency = currency conf }
signOut :: ActionM ()
signOut = do
diff --git a/src/server/Controller/Payment.hs b/src/server/Controller/Payment.hs
index 432603b..ec241f7 100644
--- a/src/server/Controller/Payment.hs
+++ b/src/server/Controller/Payment.hs
@@ -29,7 +29,6 @@ import Model.Database
import qualified Model.Payment as P
import Model.Frequency
import Model.Json.Number
-import Model.Message
import Model.Message.Key (Key(PaymentNotDeleted))
getPayments :: ActionM ()
diff --git a/src/server/Controller/SignIn.hs b/src/server/Controller/SignIn.hs
index d4a1e25..0153784 100644
--- a/src/server/Controller/SignIn.hs
+++ b/src/server/Controller/SignIn.hs
@@ -22,7 +22,7 @@ import Data.Maybe (isJust)
import qualified LoginSession
-import Config
+import Conf
import SendMail
@@ -38,15 +38,15 @@ import Secure (getUserFromToken)
import qualified View.Mail.SignIn as SignIn
-signIn :: Config -> Text -> ActionM ()
-signIn config login =
+signIn :: Conf -> Text -> ActionM ()
+signIn conf login =
if Email.isValid (TE.encodeUtf8 login)
then do
maybeUser <- liftIO . runDb $ getUser login
case maybeUser of
Just user -> do
token <- liftIO . runDb $ createSignInToken login
- let url = T.concat ["http://", hostname config, "/validateSignIn?token=", token]
+ let url = T.concat ["http://", hostname conf, "/validateSignIn?token=", token]
maybeSentMail <- liftIO . sendMail $ SignIn.getMail (entityVal user) url [login]
case maybeSentMail of
Right _ ->
@@ -61,28 +61,28 @@ signIn config login =
status badRequest400
text . TL.pack . show $ EnterValidEmail
-validateSignIn :: Config -> Text -> ActionM ()
-validateSignIn config textToken = do
+validateSignIn :: Conf -> Text -> ActionM ()
+validateSignIn conf textToken = do
alreadySigned <- isAlreadySigned
if alreadySigned
then
redirect "/"
else do
- mbSignIn <- liftIO . runDb $ getSignInToken textToken
+ mbSignIn <- liftIO . runDb $ getSignIn textToken
now <- liftIO getCurrentTime
case mbSignIn of
- Just signIn ->
- if signInIsUsed . entityVal $ signIn
+ Just signInValue ->
+ if signInIsUsed . entityVal $ signInValue
then
redirectError (getMessage SignInUsed)
else
- let diffTime = now `diffUTCTime` (signInCreation . entityVal $ signIn)
- in if diffTime > (fromIntegral $ (signInExpirationMn config) * 60)
+ let diffTime = now `diffUTCTime` (signInCreation . entityVal $ signInValue)
+ in if diffTime > (fromIntegral $ (signInExpirationMn conf) * 60)
then
redirectError (getMessage SignInExpired)
else do
- LoginSession.put (signInToken . entityVal $ signIn)
- liftIO . runDb . signInTokenToUsed . entityKey $ signIn
+ LoginSession.put (signInToken . entityVal $ signInValue)
+ liftIO . runDb . signInTokenToUsed . entityKey $ signInValue
redirect "/"
Nothing ->
redirectError (getMessage SignInInvalid)