Fixes bug where cached JWT token could prevent default admin creation

This commit is contained in:
Tzahi12345
2020-08-24 02:44:39 -04:00
parent 8fb8543829
commit f874617965

View File

@@ -398,6 +398,8 @@ export class PostsService implements CanActivate {
}, err => { }, err => {
if (err.status === 401) { if (err.status === 401) {
this.sendToLogin(); this.sendToLogin();
this.token = null;
this.resetHttpParams();
} }
console.log(err); console.log(err);
}); });
@@ -414,14 +416,7 @@ export class PostsService implements CanActivate {
this.router.navigate(['/login']); this.router.navigate(['/login']);
} }
// resets http params this.resetHttpParams();
this.http_params = `apiKey=${this.auth_token}&sessionID=${this.session_id}`
this.httpOptions = {
params: new HttpParams({
fromString: this.http_params
}),
};
} }
// user methods // user methods
@@ -446,6 +441,17 @@ export class PostsService implements CanActivate {
this.openSnackBar('You must log in to access this page!'); this.openSnackBar('You must log in to access this page!');
} }
resetHttpParams() {
// resets http params
this.http_params = `apiKey=${this.auth_token}&sessionID=${this.session_id}`
this.httpOptions = {
params: new HttpParams({
fromString: this.http_params
}),
};
}
setInitialized() { setInitialized() {
this.service_initialized.next(true); this.service_initialized.next(true);
this.initialized = true; this.initialized = true;