feat: enhance user authentication and profile retrieval
- Updated GET handler in auth route to fetch user UUID from cookie using AuthService. - Improved error handling for unauthenticated and non-existent users. - Added team name retrieval for the user profile, with fallback handling. - Refactored AuthClient to return detailed user information including team details. - Enhanced navigation component to use a dropdown menu for user actions, improving UI/UX. - Implemented loading state in UserContext to manage user info fetching.
This commit is contained in:
@@ -51,9 +51,23 @@ export class AuthClient extends BaseHttpClient {
|
||||
/**
|
||||
* Récupère l'utilisateur actuel depuis le cookie
|
||||
*/
|
||||
async getCurrentUser(): Promise<UserProfile | null> {
|
||||
async getCurrentUser(): Promise<{
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
uuid: string;
|
||||
} | null> {
|
||||
try {
|
||||
const response = await this.get<{ user: UserProfile }>("/auth");
|
||||
const response = await this.get<{
|
||||
user: {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
teamId: string;
|
||||
teamName: string;
|
||||
uuid: string;
|
||||
};
|
||||
}>("/auth");
|
||||
return response.user;
|
||||
} catch (error) {
|
||||
console.error("Failed to get current user:", error);
|
||||
|
||||
Reference in New Issue
Block a user