From 70cbe5b682ed4331d2e787a298c919bc92b9925d Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Wed, 5 Apr 2023 12:50:15 +0200 Subject: [PATCH] elm-format --- src/Internal/Api/Credentials.elm | 2 ++ src/Internal/Tools/LoginValues.elm | 8 +++++--- src/Internal/Vault.elm | 2 ++ src/Matrix.elm | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Internal/Api/Credentials.elm b/src/Internal/Api/Credentials.elm index 556ef7d..0f767c4 100644 --- a/src/Internal/Api/Credentials.elm +++ b/src/Internal/Api/Credentials.elm @@ -76,12 +76,14 @@ fromBaseUrl url = , 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. -} versions : Credentials -> Maybe V.Versions diff --git a/src/Internal/Tools/LoginValues.elm b/src/Internal/Tools/LoginValues.elm index f7a2a8f..83f8956 100644 --- a/src/Internal/Tools/LoginValues.elm +++ b/src/Internal/Tools/LoginValues.elm @@ -56,21 +56,23 @@ getToken t = UsernameAndPassword { 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 s t = case t of diff --git a/src/Internal/Vault.elm b/src/Internal/Vault.elm index 3ae756c..e0a5987 100644 --- a/src/Internal/Vault.elm +++ b/src/Internal/Vault.elm @@ -334,10 +334,12 @@ updateWith vaultUpdate ((Vault ({ cred, context } as data)) as vault) = LoggedInWithUsernameAndPassword _ output -> Vault { data | context = Credentials.addToken output.accessToken context } + getUsername : Vault -> Maybe String getUsername (Vault { context }) = Credentials.getUserId context + {-| Set personal account data -} setAccountData : String -> E.Value -> Vault -> Task X.Error VaultUpdate diff --git a/src/Matrix.elm b/src/Matrix.elm index 7bee038..e791d07 100644 --- a/src/Matrix.elm +++ b/src/Matrix.elm @@ -137,6 +137,7 @@ accountData = 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 =