refactor: simplify user service and update routes

This commit is contained in:
Constantin Simonis 2025-05-07 14:39:10 +02:00
commit 3b95725d88
No known key found for this signature in database
GPG key ID: 3878FF77C24AF4D2
12 changed files with 24 additions and 115 deletions

View file

@ -6,7 +6,7 @@ import { LoginRequest } from '../model/auth/LoginRequest';
import { RegisterRequest } from '../model/auth/RegisterRequest';
import { AuthResponse } from '../model/auth/AuthResponse';
import { User } from '../model/User';
import { environment } from '../../environments/environment';
import { environment } from '@environments/environment';
const TOKEN_KEY = 'auth-token';
const USER_KEY = 'auth-user';
@ -15,8 +15,8 @@ const USER_KEY = 'auth-user';
providedIn: 'root',
})
export class AuthService {
private authUrl = `${environment.apiUrl}/api/auth`;
private userUrl = `${environment.apiUrl}/api/users`;
private authUrl = `${environment.apiUrl}/auth`;
private userUrl = `${environment.apiUrl}/users`;
private currentUserSubject: BehaviorSubject<User | null>;
public currentUser: Observable<User | null>;
@ -30,7 +30,10 @@ export class AuthService {
// Check if token exists and load user data
if (this.getToken()) {
console.log('Token found, loading user data...');
this.loadCurrentUser();
} else {
console.log('No token found, user not logged in.');
}
}