Refactor reloadUsername in auth.service to remove debug logs, simplify subscription handling, and add null check before invocation.
This commit is contained in:
parent
4222df87a3
commit
238c5d9644
|
|
@ -47,17 +47,14 @@ export class AuthService {
|
|||
}
|
||||
|
||||
private reloadUsername() {
|
||||
console.log("Reloading username");
|
||||
this.loginService.getUsername().pipe(
|
||||
tap(username => {
|
||||
console.log("Username: ", username);
|
||||
this.loginService.getUsername().subscribe({
|
||||
next: (username) => {
|
||||
this._username.set(username.username);
|
||||
}),
|
||||
catchError(error => {
|
||||
console.log("Error: ", error);
|
||||
},
|
||||
error: (error) => {
|
||||
return throwError(() => error);
|
||||
})
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -90,7 +87,9 @@ export class AuthService {
|
|||
console.log("User claims: ", claims);
|
||||
this.userClaimsSubject.next(claims);
|
||||
this.isAuthenticatedSubject.next(true);
|
||||
this.reloadUsername();
|
||||
if (this.username() == null) {
|
||||
this.reloadUsername();
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
this.logout();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user