Skip to content

Commit

Permalink
fixes a race when logging out
Browse files Browse the repository at this point in the history
If the logout request does not complete in time, the browser does not
update the cookie as expired. We now wait for the logout request to
succeed before reloading

fixes #16
  • Loading branch information
Adnan Abdulhussein committed Nov 15, 2017
1 parent 0464a00 commit b791997
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/app/header-bar/header-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ export class HeaderBarComponent implements OnInit {
}

logout() {
this.authService.logout();
window.location.reload();
this.authService.logout().subscribe(() => {
window.location.reload();
});
}

searchCharts(input: HTMLInputElement): void {
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export class AuthService {
/**
* Logs user out
*/
logout() {
logout(): Observable<Response> {
this.cookieService.remove('ka_claims');
this.http.delete(`${this.hostname}/auth/logout`, {withCredentials: true}).subscribe();
return this.http.delete(`${this.hostname}/auth/logout`, {withCredentials: true});
}
}

0 comments on commit b791997

Please sign in to comment.