Skip to content
Permalink
Browse files
fix: clear tokens when calling $auth.reset() (#544)
fixes #172
  • Loading branch information
JoaoPedroAS51 committed Mar 3, 2020
1 parent d3a0b3e commit ab75ebcd54d45c79d060b810cfd2ba90fd5738ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
@@ -35,7 +35,7 @@ export default class LocalScheme {
}

// Ditch any leftover local tokens before attempting to log in
await this._logoutLocally()
await this.$auth.reset()

const result = await this.$auth.request(
endpoint,
@@ -93,16 +93,20 @@ export default class LocalScheme {
.catch(() => { })
}

// But logout locally regardless
return this._logoutLocally()
// But reset regardless
return this.$auth.reset()
}

async _logoutLocally () {
async reset () {
if (this.options.tokenRequired) {
this._clearToken()
}

return this.$auth.reset()
this.$auth.setUser(false)
this.$auth.setToken(this.name, false)
this.$auth.setRefreshToken(this.name, false)

return Promise.resolve()
}
}

@@ -67,9 +67,14 @@ export default class Oauth2Scheme {
this.$auth.ctx.app.$axios.setHeader(this.options.tokenName, false)
}

async logout () {
async reset () {
this._clearToken()
return this.$auth.reset()

this.$auth.setUser(false)
this.$auth.setToken(this.name, false)
this.$auth.setRefreshToken(this.name, false)

return Promise.resolve()
}

login ({ params, state, nonce } = {}) {

0 comments on commit ab75ebc

Please sign in to comment.