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

Reset Axios token/header on reset/logout #57

Closed
fanckush opened this issue Feb 6, 2018 · 6 comments
Closed

Reset Axios token/header on reset/logout #57

fanckush opened this issue Feb 6, 2018 · 6 comments
Milestone

Comments

@fanckush
Copy link

fanckush commented Feb 6, 2018

Hi agian,

When the user logs in auth module sets the headers in axios with the authentication header which is cool but when the user logs out, the reset() method does not empty/reset the header, so unless the page is refreshed the user is still logged in when making api requests

This question is available on Nuxt.js community (#c40)
@fanckush
Copy link
Author

fanckush commented Feb 6, 2018

So adding something like
this.$axios.setHeader('Authorization', null) to reset() should do it

for those who have the same issue you can add:
this.$axios.setHeader('Authorization', null) to whatever log out method you are using manually until this is implemented.

i'd love to contribute with a PR but this is such a tiny detail 😅

@danjac
Copy link

danjac commented Feb 7, 2018

This is my workaround:

export default {
  methods: {
    async logout () {
      await this.$auth.logout()
      this.$axios.setHeader('Authorization', null)
    }
  }
}

@alexdilley
Copy link

Or more simply (ref):

this.$axios.setToken(false)

@breakingrobot breakingrobot added this to the 4.0 milestone Feb 13, 2018
@fanckush fanckush mentioned this issue Feb 13, 2018
@dfcook
Copy link
Contributor

dfcook commented Mar 5, 2018

Fixed in #84

@pi0 pi0 closed this as completed Mar 6, 2018
@pi0 pi0 reopened this Mar 6, 2018
@breakingrobot
Copy link
Contributor

breakingrobot commented Mar 12, 2018

Why this has been re-opened @pi0 ?

@pi0
Copy link
Member

pi0 commented Apr 2, 2018

Fixed and released in 4.0.0.

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

6 participants