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