Skip to content

Commit ab75ebc

Browse files
fix: clear tokens when calling $auth.reset() (#544)
fixes #172
1 parent d3a0b3e commit ab75ebc

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

lib/schemes/local.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class LocalScheme {
3535
}
3636

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

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

96-
// But logout locally regardless
97-
return this._logoutLocally()
96+
// But reset regardless
97+
return this.$auth.reset()
9898
}
9999

100-
async _logoutLocally () {
100+
async reset () {
101101
if (this.options.tokenRequired) {
102102
this._clearToken()
103103
}
104104

105-
return this.$auth.reset()
105+
this.$auth.setUser(false)
106+
this.$auth.setToken(this.name, false)
107+
this.$auth.setRefreshToken(this.name, false)
108+
109+
return Promise.resolve()
106110
}
107111
}
108112

lib/schemes/oauth2.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ export default class Oauth2Scheme {
6767
this.$auth.ctx.app.$axios.setHeader(this.options.tokenName, false)
6868
}
6969

70-
async logout () {
70+
async reset () {
7171
this._clearToken()
72-
return this.$auth.reset()
72+
73+
this.$auth.setUser(false)
74+
this.$auth.setToken(this.name, false)
75+
this.$auth.setRefreshToken(this.name, false)
76+
77+
return Promise.resolve()
7378
}
7479

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

0 commit comments

Comments
 (0)