AuthForm: WS disconnection on successful authentication.

master
Philippe Pittoli 2023-06-02 00:53:01 +02:00
parent e44b1aebe9
commit 7804dd6647
1 changed files with 9 additions and 0 deletions

View File

@ -141,6 +141,7 @@ data Action
| HandleLoginInputUpdate String | HandleLoginInputUpdate String
| HandlePassInputUpdate String | HandlePassInputUpdate String
| AuthenticationAttempt Event | AuthenticationAttempt Event
| Finalize
| HandleWebSocket (WebSocketEvent WebSocketMessageType) | HandleWebSocket (WebSocketEvent WebSocketMessageType)
type State = type State =
@ -161,6 +162,7 @@ component =
, eval: H.mkEval $ H.defaultEval , eval: H.mkEval $ H.defaultEval
{ initialize = Just Initialize { initialize = Just Initialize
, handleAction = handleAction , handleAction = handleAction
, finalize = Just Finalize
} }
} }
@ -259,6 +261,13 @@ handleAction = case _ of
Initialize -> Initialize ->
handleAction ConnectWebSocket handleAction ConnectWebSocket
Finalize -> do
{ wsConnection } <- H.get
systemMessage "Finalize"
case wsConnection of
Nothing -> systemMessage "No socket? How is that even possible?"
Just socket -> H.liftEffect $ WS.close socket
WebSocketParseError error -> WebSocketParseError error ->
systemMessage $ renderError (UnknownError error) systemMessage $ renderError (UnknownError error)