Skip to content

Commit

Permalink
CU-8688ucrbp minor auth tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ucswift committed Aug 17, 2024
1 parent 37e2aca commit f34d722
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"latex",
"plaintext",
"typescript"
],
"cSpell.words": [
"Resgrid"
]
}
5 changes: 4 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,8 @@
}
}
},
"defaultProject": "ResgridAppShared"
"defaultProject": "ResgridAppShared",
"cli": {
"analytics": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export class HttpsRequestInterceptor implements HttpInterceptor {
return next.handle(dupReq);
}),
catchError((err) => {
this.authService.logout();
this.authService.logout().then(() => {
this.logger.logDebug('User logged out due to 401 error');
});
return throwError(() => err);
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ export class AuthService {
return this.getTokens(user, 'password');
}

public logout(): void {
public async logout(): Promise<void> {
this.updateState({ profile: undefined, tokens: undefined });
if (this.refreshSubscription$) {
this.refreshSubscription$.unsubscribe();
this.refreshSubscription$ = undefined;
}
this.removeToken();
return await this.removeToken();
}

public refreshTokens(): Observable<ProfileModel | null> {
Expand Down Expand Up @@ -143,8 +144,8 @@ export class AuthService {
return null;
}

private removeToken(): void {
this.storageService.remove('auth-tokens');
private async removeToken(): Promise<void> {
await this.storageService.remove('auth-tokens');
}

private updateState(newState: AuthStateModel): void {
Expand Down Expand Up @@ -230,8 +231,8 @@ export class AuthService {
return this.refreshTokens();
}),
catchError((error: any) => {
this.logout();
this.updateState({ authReady: true });
//await this.logout();
//this.updateState({ authReady: true });
return of(error);
})
);
Expand Down

0 comments on commit f34d722

Please sign in to comment.