diff --git a/src/Applications/UI/Authentication/State.elm b/src/Applications/UI/Authentication/State.elm index 4fb1b3c4..993b0bd3 100644 --- a/src/Applications/UI/Authentication/State.elm +++ b/src/Applications/UI/Authentication/State.elm @@ -104,7 +104,7 @@ initialCommand url = case Dict.get "code" (Url.queryDictionary url) of Just code -> Dropbox.exchangeAuthCode - (GotDropboxTokens Dropbox.Code) + ExchangeDropboxAuthCode url code @@ -146,12 +146,12 @@ update msg = CancelFlow -> cancelFlow + ExchangeDropboxAuthCode a -> + exchangeDropboxAuthCode a + GetStarted -> startFlow - GotDropboxTokens a b -> - gotDropboxTokens a b - NotAuthenticated -> notAuthenticated @@ -319,10 +319,10 @@ externalAuth method string model = Return.singleton model -gotDropboxTokens : Dropbox.TokenFlow -> Result Http.Error Dropbox.Tokens -> Manager -gotDropboxTokens flow result model = - case ( flow, result ) of - ( Dropbox.Code, Ok tokens ) -> +exchangeDropboxAuthCode : Result Http.Error Dropbox.Tokens -> Manager +exchangeDropboxAuthCode result model = + case result of + Ok tokens -> case tokens.refreshToken of Just refreshToken -> Nothing @@ -342,11 +342,7 @@ gotDropboxTokens flow result model = |> showNotificationWithModel (Lens.replace lens model Unauthenticated) - ( Dropbox.Refresh, Ok tokens ) -> - -- TODO - Return.singleton model - - ( _, Err err ) -> + Err err -> [] |> Notifications.errorWithCode "Failed to authenticate with Dropbox" diff --git a/src/Applications/UI/Authentication/Types.elm b/src/Applications/UI/Authentication/Types.elm index 2af30094..25630f20 100644 --- a/src/Applications/UI/Authentication/Types.elm +++ b/src/Applications/UI/Authentication/Types.elm @@ -38,8 +38,8 @@ type Msg -- | BootFailure String | CancelFlow + | ExchangeDropboxAuthCode (Result Http.Error Dropbox.Tokens) | GetStarted - | GotDropboxTokens Dropbox.TokenFlow (Result Http.Error Dropbox.Tokens) | NotAuthenticated | RemoteStorageWebfinger RemoteStorage.Attributes (Result Http.Error String) | ShowMoreOptions Mouse.Event diff --git a/src/Library/User/Layer/Methods/Dropbox.elm b/src/Library/User/Layer/Methods/Dropbox.elm index d91e1675..27242169 100644 --- a/src/Library/User/Layer/Methods/Dropbox.elm +++ b/src/Library/User/Layer/Methods/Dropbox.elm @@ -13,11 +13,6 @@ import Url exposing (Url) -- 🌳 -type TokenFlow - = Code - | Refresh - - type alias Tokens = { accessToken : String , expiresIn : Int -- Time in seconds the access token expires in