Authentication page: automatic change tabs, keep login info.

This commit is contained in:
Philippe Pittoli 2024-03-21 01:13:50 +01:00
parent f19d3f0f85
commit 041546279e
2 changed files with 10 additions and 3 deletions

View File

@ -495,8 +495,9 @@ handleAction = case _ of
handleAction $ Log $ ErrorLog "TODO: received a GotPermissionCheck message." handleAction $ Log $ ErrorLog "TODO: received a GotPermissionCheck message."
(AuthD.GotPermissionSet _) -> do (AuthD.GotPermissionSet _) -> do
handleAction $ Log $ ErrorLog "Received a GotPermissionSet message." handleAction $ Log $ ErrorLog "Received a GotPermissionSet message."
(AuthD.GotPasswordRecovered _) -> do m@(AuthD.GotPasswordRecovered _) -> do
handleAction $ Log $ SuccessLog "your new password is now valid!" handleAction $ Log $ SuccessLog "your new password is now valid!"
handleAction $ DispatchAuthDaemonMessage m
m@(AuthD.GotMatchingUsers _) -> do m@(AuthD.GotMatchingUsers _) -> do
{ current_page } <- H.get { current_page } <- H.get
case current_page of case current_page of

View File

@ -375,9 +375,13 @@ handleAction = case _ of
-- Store the current tab we are on and restore it when we reload. -- Store the current tab we are on and restore it when we reload.
sessionstorage <- H.liftEffect $ Window.sessionStorage =<< HTML.window sessionstorage <- H.liftEffect $ Window.sessionStorage =<< HTML.window
_ <- case current_tab of _ <- case current_tab of
Auth -> H.liftEffect $ Storage.setItem "current-auth-tab" "Auth" sessionstorage Auth -> do
H.modify_ \state -> state { authenticationForm { login = state.newPasswordForm.login } }
H.liftEffect $ Storage.setItem "current-auth-tab" "Auth" sessionstorage
TabPasswordRecovery -> H.liftEffect $ Storage.setItem "current-auth-tab" "TabPasswordRecovery" sessionstorage TabPasswordRecovery -> H.liftEffect $ Storage.setItem "current-auth-tab" "TabPasswordRecovery" sessionstorage
Recovery -> H.liftEffect $ Storage.setItem "current-auth-tab" "Recovery" sessionstorage Recovery -> do
H.modify_ \state -> state { newPasswordForm { login = state.passwordRecoveryForm.login } }
H.liftEffect $ Storage.setItem "current-auth-tab" "Recovery" sessionstorage
H.modify_ _ { current_tab = current_tab } H.modify_ _ { current_tab = current_tab }
handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a) handleQuery :: forall a m. MonadAff m => Query a -> H.HalogenM State Action () Output m (Maybe a)
@ -386,6 +390,8 @@ handleQuery = case _ of
-- Error messages are simply logged (see the code in the Container component). -- Error messages are simply logged (see the code in the Container component).
MessageReceived message _ -> do MessageReceived message _ -> do
case message of case message of
AuthD.GotPasswordRecovered _ -> do
handleAction $ ChangeTab Auth
AuthD.GotPasswordRecoverySent _ -> do AuthD.GotPasswordRecoverySent _ -> do
handleAction $ ChangeTab Recovery handleAction $ ChangeTab Recovery
_ -> do _ -> do