From 238c5d96440ae420f32e2511a3afa4ef09bcd25d Mon Sep 17 00:00:00 2001 From: akastijn Date: Tue, 5 Aug 2025 23:29:37 +0200 Subject: [PATCH] Refactor `reloadUsername` in `auth.service` to remove debug logs, simplify subscription handling, and add null check before invocation. --- frontend/src/app/services/auth.service.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/services/auth.service.ts b/frontend/src/app/services/auth.service.ts index bfbcec5..13a10ab 100644 --- a/frontend/src/app/services/auth.service.ts +++ b/frontend/src/app/services/auth.service.ts @@ -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();