From 55f39c070c9e059c4d0a225a4ee069dc08c3e7ba Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 25 Mar 2024 00:41:36 +0100 Subject: [PATCH] Password recovery: now tries the password before sending the request. --- src/App/Page/Authentication.purs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/App/Page/Authentication.purs b/src/App/Page/Authentication.purs index 04d5b30..82d07a3 100644 --- a/src/App/Page/Authentication.purs +++ b/src/App/Page/Authentication.purs @@ -341,7 +341,6 @@ handleAction = case _ of _ -> do H.modify_ _ { errors = [] } H.raise $ AskPasswordRecovery (Left email) - -- TODO: verify the login? NewPasswordAttempt ev -> do H.liftEffect $ Event.preventDefault ev @@ -349,13 +348,15 @@ handleAction = case _ of let { login, token, password, confirmation} = newPasswordForm if A.any (_ == "") [ login, token, password, confirmation ] - then H.raise $ Log $ ErrorLog "All entries are required!" + then H.raise $ Log $ ErrorLog "All entries are required" else if password == confirmation - then case L.login login of - Left errors -> H.modify_ _ { errors = [ Login errors ] } - Right _ -> do H.modify_ _ { errors = [] } - H.raise $ PasswordRecovery login token password - else H.raise $ Log $ UnableToSend "Confirmation differs from password!" + then case L.login login, P.password password of + Left errors, _ -> H.modify_ _ { errors = [ Login errors ] } + _, Left errors -> H.modify_ _ { errors = [ Password errors ] } + _, _ -> do H.modify_ _ { errors = [] } + H.raise $ Log $ SystemLog $ "Sending a new password" + H.raise $ PasswordRecovery login token password + else H.raise $ Log $ UnableToSend "Confirmation differs from password" ChangeTab current_tab -> do -- Store the current tab we are on and restore it when we reload.