aboutsummaryrefslogtreecommitdiff
path: root/server/src/Controller
diff options
context:
space:
mode:
authorJoris2017-11-13 23:56:40 +0100
committerJoris2017-11-14 00:03:10 +0100
commit5a63f7be9375e3ab888e4232dd7ef72c2f1ffae1 (patch)
tree4884de1d03bc47ba8f06b2cf68365d9eed9e0d39 /server/src/Controller
parent213cf7ede058b781fc957de2cd9f6a5988c08004 (diff)
Setup stylish-haskell
Diffstat (limited to 'server/src/Controller')
-rw-r--r--server/src/Controller/Category.hs23
-rw-r--r--server/src/Controller/Income.hs21
-rw-r--r--server/src/Controller/Index.hs36
-rw-r--r--server/src/Controller/Payment.hs22
-rw-r--r--server/src/Controller/SignIn.hs32
5 files changed, 69 insertions, 65 deletions
diff --git a/server/src/Controller/Category.hs b/server/src/Controller/Category.hs
index d6ed2f2..a646496 100644
--- a/server/src/Controller/Category.hs
+++ b/server/src/Controller/Category.hs
@@ -6,19 +6,20 @@ module Controller.Category
, delete
) where
-import Control.Monad.IO.Class (liftIO)
-import Network.HTTP.Types.Status (ok200, badRequest400)
-import qualified Data.Text.Lazy as TL
-import Web.Scotty hiding (delete)
+import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text.Lazy as TL
+import Network.HTTP.Types.Status (badRequest400, ok200)
+import Web.Scotty hiding (delete)
-import qualified Common.Message as Message
-import qualified Common.Message.Key as Key
-import Common.Model (CategoryId, CreateCategory(..), EditCategory(..))
+import qualified Common.Message as Message
+import qualified Common.Message.Key as Key
+import Common.Model (CategoryId, CreateCategory (..),
+ EditCategory (..))
-import Json (jsonId)
-import qualified Model.Category as Category
-import qualified Model.PaymentCategory as PaymentCategory
-import qualified Model.Query as Query
+import Json (jsonId)
+import qualified Model.Category as Category
+import qualified Model.PaymentCategory as PaymentCategory
+import qualified Model.Query as Query
import qualified Secure
create :: CreateCategory -> ActionM ()
diff --git a/server/src/Controller/Income.hs b/server/src/Controller/Income.hs
index 148b713..c42f6a7 100644
--- a/server/src/Controller/Income.hs
+++ b/server/src/Controller/Income.hs
@@ -6,18 +6,19 @@ module Controller.Income
, deleteOwn
) where
-import Control.Monad.IO.Class (liftIO)
-import Network.HTTP.Types.Status (ok200, badRequest400)
-import qualified Data.Text.Lazy as TL
-import Web.Scotty
+import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text.Lazy as TL
+import Network.HTTP.Types.Status (badRequest400, ok200)
+import Web.Scotty
-import qualified Common.Message as Message
-import qualified Common.Message.Key as Key
-import Common.Model (CreateIncome(..), EditIncome(..), IncomeId, User(..))
+import qualified Common.Message as Message
+import qualified Common.Message.Key as Key
+import Common.Model (CreateIncome (..), EditIncome (..),
+ IncomeId, User (..))
-import Json (jsonId)
-import qualified Model.Income as Income
-import qualified Model.Query as Query
+import Json (jsonId)
+import qualified Model.Income as Income
+import qualified Model.Query as Query
import qualified Secure
create :: CreateIncome -> ActionM ()
diff --git a/server/src/Controller/Index.hs b/server/src/Controller/Index.hs
index 8473c5c..bf4859d 100644
--- a/server/src/Controller/Index.hs
+++ b/server/src/Controller/Index.hs
@@ -3,26 +3,26 @@ module Controller.Index
, signOut
) where
-import Control.Monad.IO.Class (liftIO)
-import Data.Text (Text)
-import Data.Time.Clock (getCurrentTime, diffUTCTime)
-import Network.HTTP.Types.Status (ok200)
-import Prelude hiding (error)
-import Web.Scotty hiding (get)
+import Control.Monad.IO.Class (liftIO)
+import Data.Text (Text)
+import Data.Time.Clock (diffUTCTime, getCurrentTime)
+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 qualified Common.Message as Message
+import Common.Message.Key (Key)
+import qualified Common.Message.Key as Key
+import Common.Model (InitResult (..), User (..))
-import Conf (Conf(..))
-import Model.Init (getInit)
+import Conf (Conf (..))
import qualified LoginSession
-import qualified Model.Query as Query
-import qualified Model.SignIn as SignIn
-import qualified Model.User as User
-import Secure (getUserFromToken)
-import View.Page (page)
+import Model.Init (getInit)
+import qualified Model.Query as Query
+import qualified Model.SignIn as SignIn
+import qualified Model.User as User
+import Secure (getUserFromToken)
+import View.Page (page)
get :: Conf -> Maybe Text -> ActionM ()
get conf mbToken = do
@@ -70,7 +70,7 @@ validateSignIn conf textToken = do
SignIn.signInTokenToUsed . SignIn.id $ signIn
User.get . SignIn.email $ signIn
return $ case mbUser of
- Nothing -> Left Key.Secure_Unauthorized
+ Nothing -> Left Key.Secure_Unauthorized
Just user -> Right user
getLoggedUser :: ActionM (Maybe User)
diff --git a/server/src/Controller/Payment.hs b/server/src/Controller/Payment.hs
index dc10311..e4104eb 100644
--- a/server/src/Controller/Payment.hs
+++ b/server/src/Controller/Payment.hs
@@ -7,16 +7,18 @@ module Controller.Payment
, deleteOwn
) where
-import Control.Monad.IO.Class (liftIO)
-import Network.HTTP.Types.Status (ok200, badRequest400)
-import Web.Scotty
-
-import Common.Model (PaymentId, User(..), CreatePayment(..), EditPayment(..))
-
-import Json (jsonId)
-import qualified Model.Payment as Payment
-import qualified Model.PaymentCategory as PaymentCategory
-import qualified Model.Query as Query
+import Control.Monad.IO.Class (liftIO)
+import Network.HTTP.Types.Status (badRequest400, ok200)
+import Web.Scotty
+
+import Common.Model (CreatePayment (..),
+ EditPayment (..), PaymentId,
+ User (..))
+
+import Json (jsonId)
+import qualified Model.Payment as Payment
+import qualified Model.PaymentCategory as PaymentCategory
+import qualified Model.Query as Query
import qualified Secure
list :: ActionM ()
diff --git a/server/src/Controller/SignIn.hs b/server/src/Controller/SignIn.hs
index 0086fa5..5552781 100644
--- a/server/src/Controller/SignIn.hs
+++ b/server/src/Controller/SignIn.hs
@@ -4,25 +4,25 @@ module Controller.SignIn
( signIn
) where
-import Control.Monad.IO.Class (liftIO)
-import Network.HTTP.Types.Status (ok200, badRequest400)
-import qualified Data.Text as T
-import qualified Data.Text.Encoding as TE
-import qualified Data.Text.Lazy as TL
-import Web.Scotty
+import Control.Monad.IO.Class (liftIO)
+import qualified Data.Text as T
+import qualified Data.Text.Encoding as TE
+import qualified Data.Text.Lazy as TL
+import Network.HTTP.Types.Status (badRequest400, ok200)
+import Web.Scotty
-import qualified Common.Message as Message
-import qualified Common.Message.Key as Key
-import Common.Model (SignIn(..))
+import qualified Common.Message as Message
+import qualified Common.Message.Key as Key
+import Common.Model (SignIn (..))
-import Conf (Conf)
+import Conf (Conf)
import qualified Conf
-import qualified Model.Query as Query
-import qualified Model.SignIn as SignIn
-import qualified Model.User as User
+import qualified Model.Query as Query
+import qualified Model.SignIn as SignIn
+import qualified Model.User as User
import qualified SendMail
-import qualified Text.Email.Validate as Email
-import qualified View.Mail.SignIn as SignIn
+import qualified Text.Email.Validate as Email
+import qualified View.Mail.SignIn as SignIn
signIn :: Conf -> SignIn -> ActionM ()
signIn conf (SignIn email) =
@@ -41,7 +41,7 @@ signIn conf (SignIn email) =
maybeSentMail <- liftIO . SendMail.sendMail $ SignIn.mail conf user url [email]
case maybeSentMail of
Right _ -> textKey ok200 Key.SignIn_EmailSent
- Left _ -> textKey badRequest400 Key.SignIn_EmailSendFail
+ Left _ -> textKey badRequest400 Key.SignIn_EmailSendFail
Nothing -> textKey badRequest400 Key.Secure_Unauthorized
else textKey badRequest400 Key.SignIn_EmailInvalid
where textKey st key = status st >> (text . TL.fromStrict $ Message.get key)