diff --git a/frontend/src/app/services/auth.service.ts b/frontend/src/app/services/auth.service.ts index 023fd8c..db6368d 100644 --- a/frontend/src/app/services/auth.service.ts +++ b/frontend/src/app/services/auth.service.ts @@ -1,6 +1,6 @@ import {Injectable, signal} from '@angular/core'; import {LoginService} from '@api'; -import {Observable, throwError} from 'rxjs'; +import {Observable, throwError, timer} from 'rxjs'; import {catchError, tap} from 'rxjs/operators'; import {MatSnackBar} from '@angular/material/snack-bar'; import {JwtHelperService} from '@auth0/angular-jwt'; @@ -23,7 +23,9 @@ export class AuthService { private snackBar: MatSnackBar ) { // Check if user is already logged in on service initialization - this.checkAuthStatus(); + timer(1000).subscribe(() => { + this.checkAuthStatus(); + }); } /** @@ -46,13 +48,16 @@ export class AuthService { private reloadUsername() { if (window.location.hostname === 'localhost') { + console.log("Reloading username for localhost"); this._username.set('developer'); } this.loginService.getUsername().subscribe({ next: (username) => { + console.log("Username retrieved: " + username.username); this._username.set(username.username); }, error: (error) => { + console.error("Error retrieving username:", error); return throwError(() => error); } });