Ask for Password Recovery -> I lost my password! 😟

This commit is contained in:
Philippe Pittoli 2024-03-23 17:00:56 +01:00
parent c7bd61ce36
commit 177e3f307f

View File

@ -96,7 +96,7 @@ data Action
-- | There are different tabs in the administration page. -- | There are different tabs in the administration page.
-- | For example, users can be searched (`authd`) and a list is provided. -- | For example, users can be searched (`authd`) and a list is provided.
data Tab = Auth | TabPasswordRecovery | Recovery data Tab = Auth | ILostMyPassword | Recovery
derive instance eqTab :: Eq Tab derive instance eqTab :: Eq Tab
type StateAuthenticationForm = { login :: String, pass :: String } type StateAuthenticationForm = { login :: String, pass :: String }
@ -144,16 +144,16 @@ render { wsUp, current_tab, authenticationForm, passwordRecoveryForm, newPasswor
, case wsUp of , case wsUp of
false -> Bulma.p "You are disconnected." false -> Bulma.p "You are disconnected."
true -> case current_tab of true -> case current_tab of
Auth -> Bulma.box auth_form Auth -> Bulma.box auth_form
TabPasswordRecovery -> Bulma.box passrecovery_form ILostMyPassword -> Bulma.box passrecovery_form
Recovery -> Bulma.box newpass_form Recovery -> Bulma.box newpass_form
] ]
where where
fancy_tab_bar = fancy_tab_bar =
Bulma.fancy_tabs Bulma.fancy_tabs
[ Bulma.tab_entry (is_tab_active Auth) "Authentication" (ChangeTab Auth) [ Bulma.tab_entry (is_tab_active Auth) "Authentication" (ChangeTab Auth)
, Bulma.tab_entry (is_tab_active TabPasswordRecovery) "Ask for Password Recovery" (ChangeTab TabPasswordRecovery) , Bulma.tab_entry (is_tab_active ILostMyPassword) "I lost my password! 😟" (ChangeTab ILostMyPassword)
, Bulma.tab_entry (is_tab_active Recovery) "Recover with a token" (ChangeTab Recovery) , Bulma.tab_entry (is_tab_active Recovery) "Recover with a token" (ChangeTab Recovery)
] ]
is_tab_active tab = current_tab == tab is_tab_active tab = current_tab == tab
@ -291,9 +291,9 @@ handleAction = case _ of
case old_tab of case old_tab of
Nothing -> pure unit Nothing -> pure unit
Just current_tab -> case current_tab of Just current_tab -> case current_tab of
"Auth" -> handleAction $ ChangeTab Auth "Auth" -> handleAction $ ChangeTab Auth
"TabPasswordRecovery" -> handleAction $ ChangeTab TabPasswordRecovery "ILostMyPassword" -> handleAction $ ChangeTab ILostMyPassword
"Recovery" -> handleAction $ ChangeTab Recovery "Recovery" -> handleAction $ ChangeTab Recovery
_ -> H.raise $ Log $ ErrorLog $ "Reload but cannot understand old current_tab: " <> current_tab _ -> H.raise $ Log $ ErrorLog $ "Reload but cannot understand old current_tab: " <> current_tab
HandleAuthenticationInput authinp -> do HandleAuthenticationInput authinp -> do
@ -378,7 +378,7 @@ handleAction = case _ of
Auth -> do Auth -> do
H.modify_ \state -> state { authenticationForm { login = state.newPasswordForm.login } } H.modify_ \state -> state { authenticationForm { login = state.newPasswordForm.login } }
H.liftEffect $ Storage.setItem "current-auth-tab" "Auth" sessionstorage H.liftEffect $ Storage.setItem "current-auth-tab" "Auth" sessionstorage
TabPasswordRecovery -> H.liftEffect $ Storage.setItem "current-auth-tab" "TabPasswordRecovery" sessionstorage ILostMyPassword -> H.liftEffect $ Storage.setItem "current-auth-tab" "ILostMyPassword" sessionstorage
Recovery -> do Recovery -> do
H.modify_ \state -> state { newPasswordForm { login = state.passwordRecoveryForm.login } } H.modify_ \state -> state { newPasswordForm { login = state.passwordRecoveryForm.login } }
H.liftEffect $ Storage.setItem "current-auth-tab" "Recovery" sessionstorage H.liftEffect $ Storage.setItem "current-auth-tab" "Recovery" sessionstorage