Authentication form now informs when there is a failed authentication attempt.
parent
7804dd6647
commit
c42cbbeb8a
|
@ -191,14 +191,18 @@ wrapperStyle =
|
|||
"""
|
||||
|
||||
render :: forall m. State -> H.ComponentHTML Action () m
|
||||
render { messages, loginInputText, passInputText, wsConnection, canReconnect, messageHistoryLength } =
|
||||
render { messages, loginInputText, passInputText, wsConnection, canReconnect } =
|
||||
HH.div
|
||||
[ HP.style wrapperStyle ]
|
||||
[ HH.h2_ [ HH.text "Authentication!" ]
|
||||
, HH.form
|
||||
, render_auth_form
|
||||
, render_messages
|
||||
]
|
||||
where
|
||||
|
||||
render_auth_form = HH.form
|
||||
[ HE.onSubmit AuthenticationAttempt ]
|
||||
[ HH.ul_ $ map (\msg -> HH.li_ [ HH.text msg ]) messages
|
||||
, HH.p_
|
||||
[ HH.p_
|
||||
[ HH.div_
|
||||
[ HH.input
|
||||
[ HP.style "padding: 0.5rem 0.75rem; margin-bottom: 0.25rem;"
|
||||
|
@ -226,18 +230,19 @@ render { messages, loginInputText, passInputText, wsConnection, canReconnect, me
|
|||
[ HH.text "Send Message to Server" ]
|
||||
]
|
||||
]
|
||||
, renderMaxHistoryLength messageHistoryLength
|
||||
--, renderMaxHistoryLength messageHistoryLength
|
||||
, renderReconnectButton (isNothing wsConnection && canReconnect)
|
||||
]
|
||||
]
|
||||
where
|
||||
|
||||
render_messages = HH.ul_ $ map (\msg -> HH.li_ [ HH.text msg ]) messages
|
||||
|
||||
renderFootnote :: String -> H.ComponentHTML Action () m
|
||||
renderFootnote txt =
|
||||
HH.div [ HP.style "margin-bottom: 0.125rem; color: grey;" ] [ HH.small_ [ HH.text txt ] ]
|
||||
|
||||
renderMaxHistoryLength :: Int -> H.ComponentHTML Action () m
|
||||
renderMaxHistoryLength len =
|
||||
renderFootnote ("NOTE: Maximum chat history length is " <> show len <> " messages")
|
||||
-- renderMaxHistoryLength :: Int -> H.ComponentHTML Action () m
|
||||
-- renderMaxHistoryLength len =
|
||||
-- renderFootnote ("NOTE: Maximum chat history length is " <> show len <> " messages")
|
||||
|
||||
renderReconnectButton :: Boolean -> H.ComponentHTML Action () m
|
||||
renderReconnectButton cond =
|
||||
|
@ -253,7 +258,6 @@ render { messages, loginInputText, passInputText, wsConnection, canReconnect, me
|
|||
else
|
||||
HH.p_
|
||||
[ renderFootnote "NOTE: A 'Reconnect?' button will appear if the connection drops"
|
||||
, renderFootnote "NOTE: You can type /disconnect to manually disconnect"
|
||||
]
|
||||
|
||||
handleAction :: forall m. MonadAff m => Action -> H.HalogenM State Action () Output m Unit
|
||||
|
@ -338,8 +342,8 @@ handleAction = case _ of
|
|||
Right response -> do
|
||||
case response of
|
||||
-- The authentication failed.
|
||||
(AuthD.GotError _) -> do
|
||||
appendMessage $ "[😈] Failed! (TODO: put the reason)"
|
||||
(AuthD.GotError errmsg) -> do
|
||||
appendMessage $ "[😈] Failed: " <> maybe "server didn't tell why" (\v -> v) errmsg.reason
|
||||
-- The authentication was a success!
|
||||
(AuthD.GotToken msg) -> do
|
||||
appendMessage $ "[😈] Success! user " <> (show msg.uid) <> " has token: " <> msg.token
|
||||
|
|
Loading…
Reference in New Issue