Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on getOidcUser if not logged in #192

Open
dr-waterstorm opened this issue Jul 5, 2022 · 2 comments
Open

Exception on getOidcUser if not logged in #192

dr-waterstorm opened this issue Jul 5, 2022 · 2 comments

Comments

@dr-waterstorm
Copy link

We've used vuex-oidc for quite some time in our application and it's a really nice library. Thanks a lot for your work!

If a user comes to our application we use getOidcUser to check if the user has an "old" login. However, after the last update the application always throws an error when calling getOidcUser while not logged in:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'expires_at')
    at Store.setOidcUser (vuex-oidc.esm.js:626:31)
    at wrappedMutationHandler (vuex.esm.js:853:13)

This is cause by:

setOidcUser (state, user) {
      state.user = user ? user.profile : null
      state.expires_at = user.expires_at ? user.expires_at * 1000 : null
    },

state.expires_at = user.expires_at ? user.expires_at * 1000 : null

Because even if the user is null, it still tries to access user.expires_at which then fails with an error.

Is this on purpose or is there simply a check missing? If so, I suggest adding a check or something similar to prevent the library from throwing this error when trying to get the user while not logged in.

Thank you!

@perarnborg
Copy link
Owner

Sorry about this, it looks like a mistake. I’m on the road right now, but will fix this by the end of the month. Meanwhile you will have to roll back to v3.10.3 to get rid of this errror.

@perarnborg
Copy link
Owner

@dr-waterstorm This should be fixed now in v3.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants