perarnborg / vuex-oidc

Vuejs (with vuex) wrapper for open id authentication
MIT License
232 stars 64 forks source link

Disable user profile remove event (unsetOidcAuth) #182

Open alexdeia opened 2 years ago

alexdeia commented 2 years ago

Hi. I need to keep profile data in oidcStore.profile (like firstname, lastname, etc), but removing invokes after accessTokenExpiring event.

I found this row and I tried to disable this:

context.commit('unsetOidcAuth')

https://github.com/perarnborg/vuex-oidc/blob/3afe5f12b98b73964b71607c4d068b56b82b8435/src/store/create-store-module.js#L290

but I guess vuex-oidc doesn't provide that or is it possible? In short, I want to enable/disable this event (for example, in offline I can disable it and enable if app is online).

This part of code doesn't work as I guessed because unsetOidcAuth is invoked always.

    accessTokenExpired: () => {
      ...something
    },

What am I doing wrong?

perarnborg commented 2 years ago

Sorry for not replying sooner!

I think this I this should only have removed the access token from the store rather than the whole profile - since the event is thrown when the access token expires.

Even if the id token is expired I think you still are allowed to use the information in it as long as it was valid when the client received it. 🧐

I think I will change this soon, let me just look into it a bit more first!

perarnborg commented 2 years ago

@alexdeia as of v3.11.0 there is a new storeSetting attribute called removeUserWhenTokensExpire that is set to true by default. If you set it to false I think you will get the behaviour you want!

vuexOidcCreateStoreModule(oidcSettings, { namespaced: true, removeUserWhenTokensExpire: false })