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:
|
||||
// We should actually *check* that the logout response is OK and display message
|
||||
// clear token remove user from local storage to log user out
|
||||
// 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')
|
||||
// this.user.next(undefined)
|
||||
// this.roles = []
|
||||
|
||||
// Tell server that the user has logged out
|
||||
this.api.logoutApiLogoutGet().subscribe()
|
||||
if (has_token) {
|
||||
localStorage.removeItem('token')
|
||||
}
|
||||
this.bootstrapService.get().subscribe(
|
||||
bsData => this.configService.setConf(bsData)
|
||||
)
|
||||
return has_token
|
||||
this.api.logoutApiLogoutGet().subscribe({
|
||||
next: res => {
|
||||
localStorage.removeItem('token')
|
||||
this.bootstrapService.get().subscribe(
|
||||
bsData => this.configService.setConf(bsData)
|
||||
)
|
||||
},
|
||||
error: error => {
|
||||
localStorage.removeItem('token')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
logoutAdmin(): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue