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

Auth store property undefined when logging out with $auth.logout() #589

Closed
Skylercrane23 opened this issue Apr 5, 2020 · 5 comments
Closed

Comments

@Skylercrane23
Copy link

Skylercrane23 commented Apr 5, 2020

Version

v4.9.0 / 5.0.0-1608347545.4014627

Reproduction link

https://github.com/Skylercrane23

Steps to reproduce

Use a property from the auth store like $auth.user.email (or whatever property exists) on a page where you are logging out. Right after logging out a console error displays saying the property is undefined. What I am guessing is the store is being cleared before actually being logged out by clearing tokens.

What is expected ?

if I log out, it should clear tokens and then the auth store to not have any undefined properties.

What is actually happening?

My references to auth module properties are coming back undefined for a brief second right after logging out with $auth.logout()

Additional comments?

Sorry I don't have a reproduction link.

This bug report is available on Nuxt community (#c536)
@JoaoPedroAS51
Copy link
Collaborator

JoaoPedroAS51 commented Dec 19, 2020

Hi @Skylercrane23! Thank you for reporting this issue. Sorry for closing it. I made more tests and now I was able to reproduce it. I'll work on a fix :)

EDIT: Strange, now I couldn't reproduce it anymore... I'll let it open for now. Could you try to reproduce it using latest version of v5 and see if persist?

@JoaoPedroAS51
Copy link
Collaborator

Closing here, due to inactivity. Feel free to reopen if the issue persist.

@mrleblanc101
Copy link

mrleblanc101 commented May 12, 2021

I have the same issue on a projet. I am using a custom Oauth2Scheme for Keycloak.
I end up with error when login out for propriety on $auth.user.
I can fix this by adding a v-if="$auth.user" everywhere, but this mean that these component disapear while login out.
You can see the "User Menu" and one item in the sidebar disapear while the app is login out.
As this is an Oauth2Scheme, first the app redirect to this.options.endpoints.logout ()our keycloak server), then keycloak use the redirect_uri param to redirect to the login. But this issue is that while this happening, some content of our app disapear and I think this is a bug. Did I miss somehting ?
2021-05-12 18 36 59

@mrleblanc101
Copy link

mrleblanc101 commented May 12, 2021

What seem to be the issue is that $auth.reset is called before the window.location.replace redirect to keycloack which itself redirect to the login. Shouldn't the reset only happen once we are on the login page ?

    logout() {
        if (this.options.endpoints.logout) {
            const opts = {
                client_id: this.options.clientId,
                redirect_uri: this.logoutRedirectURI,
            };
            const url = this.options.endpoints.logout + '?' + qs.stringify(opts);
            window.location.replace(url);
        }
        return this.$auth.reset();
    }

@vaheqelyan
Copy link

I have the same issue

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

No branches or pull requests

4 participants