Fix the page reload problem not routing for the right page.
This commit is contained in:
parent
529c2edae7
commit
bcc76c8378
@ -43,6 +43,8 @@
|
||||
-- |
|
||||
-- | TODO: authd administrative page
|
||||
-- |
|
||||
-- | TODO: application-level heartbeat to avoid disconnections.
|
||||
-- |
|
||||
-- | Untested features:
|
||||
-- | - mail recovery, password change
|
||||
module App.Container where
|
||||
@ -284,6 +286,15 @@ handleAction = case _ of
|
||||
|
||||
Log message -> H.tell _log unit $ AppLog.Log message
|
||||
|
||||
AuthenticateToAuthd v -> case v of
|
||||
Left token -> do
|
||||
handleAction $ Log $ SimpleLog "[🤖] authenticate to authd with a token!"
|
||||
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkAuthByToken { token }
|
||||
H.tell _ws_auth unit (WS.ToSend message)
|
||||
Right (Tuple login password) -> do
|
||||
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkLogin { login, password }
|
||||
H.tell _ws_auth unit (WS.ToSend message)
|
||||
|
||||
AuthenticateToDNSManager -> do
|
||||
state <- H.get
|
||||
case state.token of
|
||||
@ -335,7 +346,6 @@ handleAction = case _ of
|
||||
state <- H.get
|
||||
H.tell _dli unit (DomainListInterface.ProvideState state.store_DomainListInterface_state)
|
||||
|
||||
-- TODO: depending on the current page, we should provide the received message to different components.
|
||||
AuthenticationDaemonEvent ev -> case ev of
|
||||
WS.MessageReceived (Tuple _ message) -> do
|
||||
handleAction $ DecodeAuthMessage message
|
||||
@ -448,7 +458,7 @@ handleAction = case _ of
|
||||
-- The authentication was a success!
|
||||
(AuthD.GotToken msg) -> do
|
||||
handleAction $ Log $ SimpleLog $ "[🎉] Authenticated to authd!"
|
||||
H.modify_ _ { token = Just msg.token, current_page = DomainList }
|
||||
H.modify_ _ { token = Just msg.token }
|
||||
|
||||
sessionstorage <- H.liftEffect $ Window.sessionStorage =<< HTML.window
|
||||
_ <- H.liftEffect $ Storage.setItem "user-authd-token" msg.token sessionstorage
|
||||
@ -456,15 +466,6 @@ handleAction = case _ of
|
||||
handleAction AuthenticateToDNSManager
|
||||
pure unit
|
||||
|
||||
AuthenticateToAuthd v -> case v of
|
||||
Left token -> do
|
||||
handleAction $ Log $ SimpleLog "[🤖] authenticate to authd with a token!"
|
||||
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkAuthByToken { token }
|
||||
H.tell _ws_auth unit (WS.ToSend message)
|
||||
Right (Tuple login password) -> do
|
||||
message <- H.liftEffect $ AuthD.serialize $ AuthD.MkLogin { login, password }
|
||||
H.tell _ws_auth unit (WS.ToSend message)
|
||||
|
||||
-- | Send a received authentication daemon message `AuthD.AnswerMessage` to a component.
|
||||
DispatchAuthDaemonMessage message -> do
|
||||
{ current_page } <- H.get
|
||||
|
Loading…
Reference in New Issue
Block a user