Add function to get username
parent
54f99f0f05
commit
bc2d1a183b
|
@ -76,6 +76,11 @@ fromBaseUrl url =
|
||||||
, vs = Nothing
|
, vs = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{-| Get the user id registered by the `Credentials` type.
|
||||||
|
-}
|
||||||
|
getUserId : Credentials -> Maybe String
|
||||||
|
getUserId (Credentials { access }) =
|
||||||
|
Login.getUserId access
|
||||||
|
|
||||||
{-| Retrieves the spec versions from a given `Credentials` value.
|
{-| Retrieves the spec versions from a given `Credentials` value.
|
||||||
-}
|
-}
|
||||||
|
|
|
@ -56,6 +56,20 @@ getToken t =
|
||||||
UsernameAndPassword { token } ->
|
UsernameAndPassword { token } ->
|
||||||
token
|
token
|
||||||
|
|
||||||
|
getUserId : AccessToken -> Maybe String
|
||||||
|
getUserId t =
|
||||||
|
case t of
|
||||||
|
NoAccess ->
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
RawAccessToken _ ->
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
DetailedAccessToken { userId } ->
|
||||||
|
Just userId
|
||||||
|
|
||||||
|
UsernameAndPassword { userId } ->
|
||||||
|
userId
|
||||||
|
|
||||||
addToken : String -> AccessToken -> AccessToken
|
addToken : String -> AccessToken -> AccessToken
|
||||||
addToken s t =
|
addToken s t =
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Matrix exposing
|
module Matrix exposing
|
||||||
( Vault, fromLoginCredentials, fromAccessToken
|
( Vault, fromLoginCredentials, fromAccessToken
|
||||||
, sync, VaultUpdate, updateWith
|
, sync, VaultUpdate, updateWith
|
||||||
, getRooms, getRoomById, getInvites, accountData
|
, getRooms, getRoomById, getInvites, accountData, username
|
||||||
, joinRoomById, setAccountData
|
, joinRoomById, setAccountData
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ interact with the API.
|
||||||
|
|
||||||
# Exploring your vault
|
# Exploring your vault
|
||||||
|
|
||||||
@docs getRooms, getRoomById, getInvites, accountData
|
@docs getRooms, getRoomById, getInvites, accountData, username
|
||||||
|
|
||||||
|
|
||||||
# Taking action
|
# Taking action
|
||||||
|
@ -133,6 +133,16 @@ accountData =
|
||||||
Internal.Vault.accountData
|
Internal.Vault.accountData
|
||||||
|
|
||||||
|
|
||||||
|
{-| Get the username of the account that we're using.
|
||||||
|
|
||||||
|
The username is a `Maybe String` if the Vault hasn't had its first sync yet,
|
||||||
|
and the API might not always be consistent on the username.
|
||||||
|
-}
|
||||||
|
username : Vault -> Maybe String
|
||||||
|
username =
|
||||||
|
Internal.Vault.getUsername
|
||||||
|
|
||||||
|
|
||||||
{-| Join a Matrix room based on its room id.
|
{-| Join a Matrix room based on its room id.
|
||||||
-}
|
-}
|
||||||
joinRoomById : String -> Vault -> Task X.Error VaultUpdate
|
joinRoomById : String -> Vault -> Task X.Error VaultUpdate
|
||||||
|
|
Loading…
Reference in New Issue