Fix race condition on logout
This commit is contained in:
parent
96331e2450
commit
61f0175957
1 changed files with 13 additions and 10 deletions
|
@ -72,25 +72,28 @@ export class AuthenticationService {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
logout(): boolean {
|
logout() {
|
||||||
// XXX: not completly safe: the server might be down:
|
// XXX: not completly safe: the server might be down:
|
||||||
// We should actually *check* that the logout response is OK and display message
|
// We should actually *check* that the logout response is OK and display message
|
||||||
// clear token remove user from local storage to log user out
|
// clear token remove user from local storage to log user out
|
||||||
// let has_token: boolean = this.user.value && !!this.user.value.token
|
// let has_token: boolean = this.user.value && !!this.user.value.token
|
||||||
const has_token: boolean = !!localStorage.getItem('token')
|
// const has_token: boolean = !!localStorage.getItem('token')
|
||||||
// localStorage.removeItem('user')
|
// localStorage.removeItem('user')
|
||||||
// this.user.next(undefined)
|
// this.user.next(undefined)
|
||||||
// this.roles = []
|
// this.roles = []
|
||||||
|
|
||||||
// Tell server that the user has logged out
|
// Tell server that the user has logged out
|
||||||
this.api.logoutApiLogoutGet().subscribe()
|
this.api.logoutApiLogoutGet().subscribe({
|
||||||
if (has_token) {
|
next: res => {
|
||||||
localStorage.removeItem('token')
|
localStorage.removeItem('token')
|
||||||
}
|
this.bootstrapService.get().subscribe(
|
||||||
this.bootstrapService.get().subscribe(
|
bsData => this.configService.setConf(bsData)
|
||||||
bsData => this.configService.setConf(bsData)
|
)
|
||||||
)
|
},
|
||||||
return has_token
|
error: error => {
|
||||||
|
localStorage.removeItem('token')
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
logoutAdmin(): void {
|
logoutAdmin(): void {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue