UserAdded: message was correctly parsed after all.

master
Philippe Pittoli 2023-06-04 02:01:50 +02:00
parent 6c69eaea5a
commit 5f13307d86
3 changed files with 15 additions and 14 deletions

View File

@ -585,6 +585,8 @@ handleAction = case _ of
(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
H.raise $ AuthToken msg.token H.raise $ AuthToken msg.token
(AuthD.GotUserAdded msg) -> do
appendMessage $ "[😈] Success! Server added user: " <> show msg.user
-- WTH?! -- WTH?!
_ -> do _ -> do
appendMessage $ "[😈] Failed! Authentication server didn't send a valid message." appendMessage $ "[😈] Failed! Authentication server didn't send a valid message."

View File

@ -54,7 +54,7 @@ render state
= HH.div_ $ = HH.div_ $
[ render_auth_form [ render_auth_form
, div_token , div_token
, render_original_interface --, render_original_interface
--, useless_stuff --, useless_stuff
] ]
where where
@ -75,13 +75,13 @@ render state
[ HP.class_ (H.ClassName "box") ] [ HP.class_ (H.ClassName "box") ]
[ HH.p_ [ HH.text ("Token is: " <> current_token) ] ] [ HH.p_ [ HH.text ("Token is: " <> current_token) ] ]
render_original_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad --render_original_interface :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
render_original_interface = --render_original_interface =
HH.div -- HH.div
[ HP.class_ (H.ClassName "box") ] -- [ HP.class_ (H.ClassName "box") ]
[ HH.h1_ [ HH.text "Original interface" ] -- [ HH.h1_ [ HH.text "Original interface" ]
, HH.slot_ _oi unit OI.component "ws://127.0.0.1:8080" -- , HH.slot_ _oi unit OI.component "ws://127.0.0.1:8080"
] -- ]
-- useless_stuff :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad -- useless_stuff :: forall monad. MonadAff monad => H.ComponentHTML Action ChildSlots monad
-- useless_stuff = -- useless_stuff =

View File

@ -10,16 +10,15 @@ import Data.Codec.Argonaut.Record as CAR
import Data.Newtype (class Newtype) import Data.Newtype (class Newtype)
-- | Currently not the real type. -- | Currently not the real type.
-- | Lacks 'profile' and 'date_registration' attributes. -- | Lacks 'profile' attribute.
-- type UserPublic row = { login :: String, uid :: Int | row } -- TODO: add profile :: JSON any
-- TODO: add profile :: JSON any, date_registration :: Maybe Time
type UserPublic = { login :: String, uid :: Int, date_registration :: Maybe String } type UserPublic = { login :: String, uid :: Int, date_registration :: Maybe String }
-- | UserPublic.codec can be used to parse and encode public user info, -- | UserPublic.codec can be used to parse and encode public user info,
-- | which can be exchanged in different messages. -- | which can be exchanged in different messages.
codec :: JsonCodec UserPublic codec :: JsonCodec UserPublic
codec = CA.object "UserPublic" (CAR.record { "login": CA.string codec = CA.object "UserPublic" (CAR.record { login: CA.string
, "uid": CA.int , uid: CA.int
, "date_registration": CAR.optional CA.string }) , date_registration: CAR.optional CA.string })
-- {"user":{"login":"a","uid": 1003,"date_registration":"2023-06-03T03:32:10+02:00"}} -- {"user":{"login":"a","uid": 1003,"date_registration":"2023-06-03T03:32:10+02:00"}}