From cfd1ecf265b9e2810b8e05ca0a4230c77e599738 Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Tue, 30 Apr 2024 23:37:35 +0200 Subject: [PATCH] Authd: error password too long + s/!/./. --- src/App/Container.purs | 35 ++++++++++++----------- src/App/Message/AuthenticationDaemon.purs | 7 +++++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/App/Container.purs b/src/App/Container.purs index d51b24b..499311f 100644 --- a/src/App/Container.purs +++ b/src/App/Container.purs @@ -573,42 +573,45 @@ handleAction = case _ of handleAction $ AddNotif $ GoodNotification "Your password recovery mail has been sent." handleAction $ DispatchAuthDaemonMessage m (AuthD.GotErrorPasswordTooShort _) -> do - handleAction $ Log $ ErrorLog "Password too short!" + handleAction $ Log $ ErrorLog "Password too short." handleAction $ AddNotif $ BadNotification "The server told that your password is too short." (AuthD.GotErrorMailRequired _) -> do - handleAction $ Log $ ErrorLog "Email required!" + handleAction $ Log $ ErrorLog "Email required." handleAction $ AddNotif $ BadNotification "An email is required." (AuthD.GotErrorInvalidCredentials _) -> do - handleAction $ Log $ ErrorLog "Invalid credentials!" + handleAction $ Log $ ErrorLog "Invalid credentials." handleAction $ ToggleAuthenticated Nothing - handleAction $ AddNotif $ BadNotification "Invalid credentials!" + handleAction $ AddNotif $ BadNotification "Invalid credentials." (AuthD.GotErrorRegistrationsClosed _) -> do handleAction $ Log $ ErrorLog "Registration closed. Try another time or contact an administrator." handleAction $ AddNotif $ BadNotification "Registration are closed at the moment." (AuthD.GotErrorInvalidLoginFormat _) -> do - handleAction $ Log $ ErrorLog "Invalid login format!" + handleAction $ Log $ ErrorLog "Invalid login format." handleAction $ AddNotif $ BadNotification "Invalid login format." (AuthD.GotErrorInvalidEmailFormat _) -> do - handleAction $ Log $ ErrorLog "Invalid email format!" + handleAction $ Log $ ErrorLog "Invalid email format." handleAction $ AddNotif $ BadNotification "Invalid email format." (AuthD.GotErrorAlreadyUsersInDB _) -> do - handleAction $ Log $ ErrorLog "GotErrorAlreadyUsersInDB" - handleAction $ AddNotif $ BadNotification "Login already taken!" + handleAction $ Log $ ErrorLog "Login already taken." + handleAction $ AddNotif $ BadNotification "Login already taken." (AuthD.GotErrorReadOnlyProfileKeys _) -> do - handleAction $ Log $ ErrorLog "Trying to add a profile with some invalid (read-only) keys!" - handleAction $ AddNotif $ BadNotification "Trying to add a profile with some invalid (read-only) keys!" + handleAction $ Log $ ErrorLog "Trying to add a profile with some invalid (read-only) keys." + handleAction $ AddNotif $ BadNotification "Trying to add a profile with some invalid (read-only) keys." (AuthD.GotErrorInvalidActivationKey _) -> do - handleAction $ Log $ ErrorLog "Invalid activation key!" - handleAction $ AddNotif $ BadNotification "Invalid activation key!" + handleAction $ Log $ ErrorLog "Invalid activation key." + handleAction $ AddNotif $ BadNotification "Invalid activation key." (AuthD.GotErrorUserAlreadyValidated _) -> do - handleAction $ Log $ ErrorLog "User already validated!" - handleAction $ AddNotif $ BadNotification "User already validated!" + handleAction $ Log $ ErrorLog "User already validated." + handleAction $ AddNotif $ BadNotification "User already validated." (AuthD.GotErrorCannotContactUser _) -> do handleAction $ Log $ ErrorLog "User cannot be contacted. Email address may be invalid." handleAction $ AddNotif $ BadNotification "User cannot be contacted. Email address may be invalid." (AuthD.GotErrorInvalidRenewKey _) -> do - handleAction $ Log $ ErrorLog "Invalid renew key!" - handleAction $ AddNotif $ BadNotification "Invalid renew key!" + handleAction $ Log $ ErrorLog "Invalid renew key." + handleAction $ AddNotif $ BadNotification "Invalid renew key." + (AuthD.GotErrorPasswordTooLong _) -> do + handleAction $ Log $ ErrorLog "Password too long." + handleAction $ AddNotif $ BadNotification "Password too long." -- The authentication was a success! (AuthD.GotToken msg) -> do handleAction $ Log $ SuccessLog $ "Authenticated to authd." diff --git a/src/App/Message/AuthenticationDaemon.purs b/src/App/Message/AuthenticationDaemon.purs index 0b628b7..e00e9cc 100644 --- a/src/App/Message/AuthenticationDaemon.purs +++ b/src/App/Message/AuthenticationDaemon.purs @@ -339,6 +339,11 @@ type ErrorInvalidRenewKey = {} codecGotErrorInvalidRenewKey :: CA.JsonCodec ErrorInvalidRenewKey codecGotErrorInvalidRenewKey = CA.object "ErrorInvalidRenewKey" (CAR.record {}) +{- 35 -} +type ErrorPasswordTooLong = {} +codecGotErrorPasswordTooLong :: CA.JsonCodec ErrorPasswordTooLong +codecGotErrorPasswordTooLong = CA.object "ErrorPasswordTooLong" (CAR.record {}) + {- 250 -} -- type KeepAlive = { } codecGotKeepAlive ∷ CA.JsonCodec KeepAlive @@ -393,6 +398,7 @@ data AnswerMessage | GotErrorUserAlreadyValidated ErrorUserAlreadyValidated -- 32 | GotErrorCannotContactUser ErrorCannotContactUser -- 33 | GotErrorInvalidRenewKey ErrorInvalidRenewKey -- 34 + | GotErrorPasswordTooLong ErrorPasswordTooLong -- 35 | GotKeepAlive KeepAlive -- 250 encode ∷ RequestMessage -> Tuple UInt String @@ -455,6 +461,7 @@ decode number string 32 -> error_management codecGotErrorUserAlreadyValidated GotErrorUserAlreadyValidated 33 -> error_management codecGotErrorCannotContactUser GotErrorCannotContactUser 34 -> error_management codecGotErrorInvalidRenewKey GotErrorInvalidRenewKey + 35 -> error_management codecGotErrorPasswordTooLong GotErrorPasswordTooLong 250 -> error_management codecGotKeepAlive GotKeepAlive _ -> Left UnknownNumber where