refactor(lottery): improve code structure and readability
Some checks failed
CI / Get Changed Files (pull_request) Successful in 7s
CI / eslint (pull_request) Successful in 38s
CI / Docker frontend validation (pull_request) Successful in 50s
CI / oxlint (pull_request) Successful in 27s
CI / prettier (pull_request) Failing after 28s
CI / Docker backend validation (pull_request) Successful in 1m23s
CI / Checkstyle Main (pull_request) Successful in 1m20s
CI / test-build (pull_request) Successful in 40s

This commit is contained in:
Jan-Marlon Leibl 2025-05-07 17:55:31 +02:00
commit 7aefe67aa0
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
5 changed files with 200 additions and 140 deletions

View file

@ -13,6 +13,19 @@ export class UserService {
private http: HttpClient = inject(HttpClient);
private authService = inject(AuthService);
constructor() {
// Initialize with the current user from AuthService if available
const currentUser = this.authService.getUser();
if (currentUser) {
this.currentUserSubject.next(currentUser);
}
// Subscribe to auth service user updates
this.authService.userSubject.subscribe(user => {
this.currentUserSubject.next(user);
});
}
public getCurrentUser(): Observable<User | null> {
return this.http.get<User | null>('/backend/users/me').pipe(
catchError(() => EMPTY),