aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/common.cabal2
-rw-r--r--common/src/Common/Message/Key.hs11
-rw-r--r--common/src/Common/Message/Translation.hs74
-rw-r--r--common/src/Common/Model.hs2
-rw-r--r--common/src/Common/Model/InitResult.hs18
-rw-r--r--common/src/Common/Model/Password.hs12
-rw-r--r--common/src/Common/Model/SignInForm.hs3
-rw-r--r--common/src/Common/Validation/Atomic.hs12
-rw-r--r--common/src/Common/Validation/SignIn.hs14
9 files changed, 39 insertions, 109 deletions
diff --git a/common/common.cabal b/common/common.cabal
index fdede8f..d09e29b 100644
--- a/common/common.cabal
+++ b/common/common.cabal
@@ -35,6 +35,7 @@ Library
Common.Model.CreateIncomeForm
Common.Model.CreatePaymentForm
Common.Model.Email
+ Common.Model.Password
Common.Model.Payment
Common.Model.SignInForm
Common.Model.User
@@ -66,6 +67,5 @@ Library
Common.Model.IncomeHeader
Common.Model.IncomePage
Common.Model.Init
- Common.Model.InitResult
Common.Model.PaymentHeader
Common.Model.PaymentPage
diff --git a/common/src/Common/Message/Key.hs b/common/src/Common/Message/Key.hs
index 2561156..b778a8f 100644
--- a/common/src/Common/Message/Key.hs
+++ b/common/src/Common/Message/Key.hs
@@ -118,16 +118,9 @@ data Key =
| SignIn_Button
| SignIn_DisconnectSuccess
- | SignIn_EmailInvalid
+ | SignIn_InvalidCredentials
| SignIn_EmailLabel
- | SignIn_EmailSendFail
- | SignIn_EmailSent
- | SignIn_LinkExpired
- | SignIn_LinkInvalid
- | SignIn_LinkUsed
- | SignIn_MailTitle
- | SignIn_MailBody Text Text
- | SignIn_ParseError
+ | SignIn_PasswordLabel
| Statistic_Title
| Statistic_ByMonthsAndMean Text
diff --git a/common/src/Common/Message/Translation.hs b/common/src/Common/Message/Translation.hs
index a86a371..e74c801 100644
--- a/common/src/Common/Message/Translation.hs
+++ b/common/src/Common/Message/Translation.hs
@@ -517,80 +517,20 @@ m l SignIn_DisconnectSuccess =
English -> "You have successfully disconnected"
French -> "Vous êtes à présent déconnecté."
-m l SignIn_EmailInvalid =
+m l SignIn_InvalidCredentials =
case l of
- English -> "Your email is not valid."
- French -> "Votre courriel n’est pas valide."
+ English -> "Your credentials are not valid."
+ French -> "Vos identifiants de connexion ne sont pas valides."
m l SignIn_EmailLabel =
case l of
English -> "Email"
French -> "Courriel"
-m l SignIn_EmailSendFail =
- case l of
- English -> "You are authorized to sign in, but we failed to send you the sign up email."
- French -> "Tu es autorisé à te connecter, mais nous n’avons pas pu t’envoyer le courriel de connexion."
-
-m l SignIn_EmailSent =
- case l of
- English -> "We sent you an email with a connexion link."
- French -> "Nous t’avons envoyé un courriel avec un lien pour te connecter."
-
-m l SignIn_LinkExpired =
- case l of
- English -> "The link expired, please sign in again."
- French -> "Le lien sur lequel tu as cliqué a expiré, connecte-toi à nouveau."
-
-m l SignIn_LinkInvalid =
- case l of
- English -> "The link is invalid, please sign in again."
- French -> "Le lien sur lequel tu as cliqué est invalide, connecte-toi à nouveau."
-
-m l SignIn_LinkUsed =
- case l of
- English -> "You already used this link, please sign in again."
- French -> "Tu as déjà utilisé ce lien, connecte-toi à nouveau."
-
-m l SignIn_MailTitle =
- case l of
- English -> T.concat [ "Sign in to ", m l App_Title ]
- French -> T.concat [ "Connexion à ", m l App_Title ]
-
-m l (SignIn_MailBody name url) =
- T.intercalate
- "\n"
- ( case l of
- English ->
- [ T.concat [ "Hi ", name, "," ]
- , ""
- , T.concat
- [ "Click to the following link in order to sign in to Shared Cost:"
- , m l App_Title
- , ":"
- ]
- , url
- , ""
- , "See you soon!"
- ]
- French ->
- [ T.concat [ "Salut ", name, "," ]
- , ""
- , T.concat
- [ "Clique sur le lien suivant pour te connecter à "
- , m l App_Title
- , ":"
- ]
- , url
- , ""
- , "À très vite !"
- ]
- )
-
-m l SignIn_ParseError =
- case l of
- English -> "Error while reading initial data."
- French -> "Erreur lors de la lecture des données initiales."
+m l SignIn_PasswordLabel =
+ case l of
+ English -> "Password"
+ French -> "Mot de passe"
m l (Statistic_ByMonthsAndMean amount) =
case l of
diff --git a/common/src/Common/Model.hs b/common/src/Common/Model.hs
index 73cbf6c..c11d6ef 100644
--- a/common/src/Common/Model.hs
+++ b/common/src/Common/Model.hs
@@ -17,7 +17,7 @@ import Common.Model.Income as X
import Common.Model.IncomeHeader as X
import Common.Model.IncomePage as X
import Common.Model.Init as X
-import Common.Model.InitResult as X
+import Common.Model.Password as X
import Common.Model.Payment as X
import Common.Model.PaymentHeader as X
import Common.Model.PaymentPage as X
diff --git a/common/src/Common/Model/InitResult.hs b/common/src/Common/Model/InitResult.hs
deleted file mode 100644
index f4c08a9..0000000
--- a/common/src/Common/Model/InitResult.hs
+++ /dev/null
@@ -1,18 +0,0 @@
-module Common.Model.InitResult
- ( InitResult(..)
- ) where
-
-import Data.Aeson (FromJSON, ToJSON)
-import Data.Text (Text)
-import GHC.Generics (Generic)
-
-import Common.Model.Init (Init)
-
-data InitResult =
- InitSuccess Init
- | InitError Text
- | InitEmpty
- deriving (Show, Generic)
-
-instance FromJSON InitResult
-instance ToJSON InitResult
diff --git a/common/src/Common/Model/Password.hs b/common/src/Common/Model/Password.hs
new file mode 100644
index 0000000..1b51a47
--- /dev/null
+++ b/common/src/Common/Model/Password.hs
@@ -0,0 +1,12 @@
+module Common.Model.Password
+ ( Password(..)
+ ) where
+
+import Data.Aeson (FromJSON, ToJSON)
+import Data.Text (Text)
+import GHC.Generics (Generic)
+
+newtype Password = Password Text deriving (Show, Generic)
+
+instance FromJSON Password
+instance ToJSON Password
diff --git a/common/src/Common/Model/SignInForm.hs b/common/src/Common/Model/SignInForm.hs
index 2b8c955..7a25935 100644
--- a/common/src/Common/Model/SignInForm.hs
+++ b/common/src/Common/Model/SignInForm.hs
@@ -7,7 +7,8 @@ import Data.Text (Text)
import GHC.Generics (Generic)
data SignInForm = SignInForm
- { _signIn_email :: Text
+ { _signInForm_email :: Text
+ , _signInForm_password :: Text
} deriving (Show, Generic)
instance FromJSON SignInForm
diff --git a/common/src/Common/Validation/Atomic.hs b/common/src/Common/Validation/Atomic.hs
index 4bb7cad..9c21e14 100644
--- a/common/src/Common/Validation/Atomic.hs
+++ b/common/src/Common/Validation/Atomic.hs
@@ -1,10 +1,11 @@
module Common.Validation.Atomic
- ( nonEmpty
+ ( color
+ , day
, minLength
- , number
+ , nonEmpty
, nonNullNumber
- , day
- , color
+ , number
+ , password
) where
import qualified Data.Char as Char
@@ -55,3 +56,6 @@ color str =
else
V.Failure (Msg.get Msg.Form_InvalidColor)
+
+password :: Text -> Validation Text Text
+password = minLength 8
diff --git a/common/src/Common/Validation/SignIn.hs b/common/src/Common/Validation/SignIn.hs
index 18ceb44..ac9cc37 100644
--- a/common/src/Common/Validation/SignIn.hs
+++ b/common/src/Common/Validation/SignIn.hs
@@ -1,19 +1,17 @@
module Common.Validation.SignIn
- ( signIn
- , email
+ ( email
+ , password
) where
import Data.Text (Text)
import Data.Validation (Validation)
import Common.Model.Email (Email (..))
-import Common.Model.SignInForm (SignInForm (..))
+import Common.Model.Password (Password (..))
import qualified Common.Validation.Atomic as Atomic
-import qualified Data.Validation as Validation
-
-signIn :: SignInForm -> Maybe Email
-signIn (SignInForm str) =
- Validation.validation (const Nothing) Just . email $ str
email :: Text -> Validation Text Email
email = fmap Email . Atomic.minLength 5
+
+password :: Text -> Validation Text Password
+password = fmap Password . Atomic.minLength 8