maxmantz/redux-oidc

On redirect, LOADING_USER and USER_EXPIRED fires just before USER_FOUND

slutske22 opened this issue · 1 comments

I am not sure if I am misunderstanding how things work, but I am seeing what feels like strange behavior. Once the user signs in to the OAuth provider (keycloak in my case), they are send back to the callback uri. The first actions fired from redux are as such:

Screen Shot 2020-12-07 at 2 38 23 PM

However, on reload, I get the expected behavior:

Screen Shot 2020-12-08 at 1 44 23 PM

The fact that USER_EXPIRED is called (and thereby makes store.oidc.isLoadingUser false) is confusing to me, and is causing some UI issues. Perhaps I'm not understanding some fundamental part of oidc, but how can I maintain in the store that the user is still being retrieved?

For some background, I call loadUser directly after the store is defined:

// in index.js
const store = createStore(rootReducer, <middleware>);
loadUser(store, userManager);

userManager is defined like this:

const userManagerConfig = {
  authority: `${window.location.protocol}//${window.location.hostname}:8081/auth/realms/master`,
  client_id: "vine",
  redirect_uri: `${window.location.protocol}//${window.location.hostname}${
    window.location.port ? `:${window.location.port}` : ""
  }${window.location.pathname}`,
  response_type: "code",
  scope: "openid",
  automaticSilentRenew: true,
  accessTokenExpiringNotificationTime: 20,
  revokeAccessTokenOnSignout: true,
  post_logout_redirect_uri: `${window.location.protocol}//${
    window.location.hostname
  }${window.location.port ? `:${window.location.port}` : ""}`
};

const userManager = createUserManager(userManagerConfig);

Hi,

sorry for the late reply. Your config looks good, I guess this can happen when the access token in your app state has expired, therefore USER_EXPIRED fires. Then the token gets renewed and USER_FOUND is dispached.