GetToken -> Login

This commit is contained in:
Philippe Pittoli 2023-06-10 18:30:31 +02:00
parent fc24bdac68
commit 9f81166110
2 changed files with 6 additions and 6 deletions

View File

@ -401,7 +401,7 @@ handleAction = case _ of
Open -> do
H.liftEffect $ do
ab <- AuthD.serialize (AuthD.MkGetToken { login: login, password: pass })
ab <- AuthD.serialize (AuthD.MkLogin { login: login, password: pass })
sendArrayBuffer webSocket ab
appendMessageReset $ "[😇] Trying to connect with login: " <> login

View File

@ -54,7 +54,7 @@ type Contacts = { user :: Int, email :: Maybe Email.Email, phone ::
type MatchingUsers = { users :: Array UserPublic.UserPublic }
type Password = String
type GetToken = { login :: String, password :: String }
type Login = { login :: String, password :: String }
type AddUser = { shared_key :: String, login :: String, password :: String, email :: Maybe Email.Email, phone :: Maybe Phone.Phone } -- profile :: Maybe Hash(String, JSON::Any)
type ValidateUser = { login :: String, activation_key :: String }
-- I'll split a message in two: either get a user by UID or by name.
@ -75,8 +75,8 @@ type Delete = { shared_key :: Maybe String, login :: Maybe String, password :: M
type GetContacts = { token :: String }
-- Related JSON codecs.
codecGetToken ∷ CA.JsonCodec GetToken
codecGetToken = CA.object "GetToken" (CAR.record { login: CA.string, password: CA.string })
codecLogin ∷ CA.JsonCodec Login
codecLogin = CA.object "Login" (CAR.record { login: CA.string, password: CA.string })
codecAddUser ∷ CA.JsonCodec AddUser
codecAddUser = CA.object "AddUser" (CAR.record { shared_key: CA.string
, login: CA.string
@ -164,7 +164,7 @@ codecGotMatchingUsers = CA.object "MatchingUsers" (CAR.record { users: CA.array
-- All possible requests.
data RequestMessage
= MkGetToken GetToken -- 0
= MkLogin Login -- 0
| MkAddUser AddUser -- 1
| MkValidateUser ValidateUser -- 2
| MkGetUserByUID GetUserByUID -- 3
@ -202,7 +202,7 @@ data AnswerMessage
encode ∷ RequestMessage -> Tuple UInt String
encode m = case m of
(MkGetToken request) -> get_tuple 0 codecGetToken request
(MkLogin request) -> get_tuple 0 codecLogin request
(MkAddUser request) -> get_tuple 1 codecAddUser request
(MkValidateUser request) -> get_tuple 2 codecValidateUser request
-- Both messages are actually a single message type, so they have the same number.