Gizra / elm-restful

Elm utilities useful for working with a RESTful backend (especially Drupal)
MIT License
3 stars 0 forks source link

Restful.Login.checkCachedCredentials should get access token as `Maybe String` #9

Closed amitaibu closed 6 years ago

amitaibu commented 6 years ago

This will allow us to prevent calling the server is we have no access token

rgrempel commented 6 years ago

If you don't have an access token, you don't have to call checkCachedCredentials at all ... you can start with loggedOut.

amitaibu commented 6 years ago

Indeed, but since this will almost always be the case, we can instead of

        ( loginStatus, loginCmd ) =
            -- We kick off the process of checking the cached credentials which
            -- we were provided.
            case flags.accessToken of
                Just accessToken ->
                    Restful.Login.checkCachedCredentials
                        loginConfig
                        flags.backendUrl
                        accessToken

                Nothing ->
                    ( Restful.Login.AnonymousUser Nothing ()
                    , Cmd.none
                    )

do the "heavy lifting" and

          -- We kick off the process of checking the cached credentials which
          -- we were provided, or default to Logged out.
        ( loginStatus, loginCmd ) =
                    Restful.Login.checkCachedCredentials
                        loginConfig
                        flags.backendUrl
                        flags.accessToken -- <- This is a Maybe
rgrempel commented 6 years ago

Ah, yes, that does seem nicer ...

rgrempel commented 6 years ago

I've added this change to #11.

rgrempel commented 6 years ago

Merged in #11.