refactor: simplify user service and update routes
This commit is contained in:
parent
51540c930b
commit
3b95725d88
12 changed files with 24 additions and 115 deletions
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue