Add logging in.

This commit is contained in:
2018-12-08 15:06:14 -08:00
parent 3656b0f3f0
commit e06c4a8772
4 changed files with 61 additions and 9 deletions

View File

@@ -6,12 +6,15 @@ import Scylla.Login exposing (loginResponseDecoder, Username, Password)
import Json.Encode exposing (object, string)
import Http exposing (request, jsonBody, expectJson)
fullUrl : ApiUrl -> ApiUrl
fullUrl s = s ++ "/_matrix/client/r0"
-- Http Requests
firstSync : ApiUrl -> ApiToken -> Cmd Msg
firstSync apiUrl token = request
{ method = "GET"
, headers = authenticatedHeaders token
, url = apiUrl ++ "/sync"
, url = (fullUrl apiUrl) ++ "/sync"
, body = jsonBody <| object []
, expect = expectJson ReceiveSyncResponse syncResponseDecoder
, timeout = Nothing
@@ -22,7 +25,7 @@ login : ApiUrl -> Username -> Password -> Cmd Msg
login apiUrl username password = request
{ method = "POST"
, headers = basicHeaders
, url = apiUrl ++ "/login"
, url = (fullUrl apiUrl) ++ "/login"
, body = jsonBody <| object
[ ("type", string "m.login.password")
, ("identifier", object