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() {
|
private reloadUsername() {
|
||||||
console.log("Reloading username");
|
this.loginService.getUsername().subscribe({
|
||||||
this.loginService.getUsername().pipe(
|
next: (username) => {
|
||||||
tap(username => {
|
|
||||||
console.log("Username: ", username);
|
|
||||||
this._username.set(username.username);
|
this._username.set(username.username);
|
||||||
}),
|
},
|
||||||
catchError(error => {
|
error: (error) => {
|
||||||
console.log("Error: ", error);
|
|
||||||
return throwError(() => error);
|
return throwError(() => error);
|
||||||
})
|
}
|
||||||
)
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -90,7 +87,9 @@ export class AuthService {
|
||||||
console.log("User claims: ", claims);
|
console.log("User claims: ", claims);
|
||||||
this.userClaimsSubject.next(claims);
|
this.userClaimsSubject.next(claims);
|
||||||
this.isAuthenticatedSubject.next(true);
|
this.isAuthenticatedSubject.next(true);
|
||||||
this.reloadUsername();
|
if (this.username() == null) {
|
||||||
|
this.reloadUsername();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logout();
|
this.logout();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user