Auth-module: Reset Axios token/header on reset/logout

Created on 6 Feb 2018  路  6Comments  路  Source: nuxt-community/auth-module

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)

Most helpful comment

Fixed and released in 4.0.0.

All 6 comments

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 馃槄

This is my workaround:

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

Or more simply (ref):

this.$axios.setToken(false)

Fixed in #84

Why this has been re-opened @pi0 ?

Fixed and released in 4.0.0.

Was this page helpful?
0 / 5 - 0 ratings