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:
36
app/account/page.tsx
Normal file
36
app/account/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { AuthService, userService, TeamsService } from "@/services";
|
||||
import { AccountForm } from "@/components/account/account-form";
|
||||
|
||||
export default async function AccountPage() {
|
||||
try {
|
||||
// Vérifier si l'utilisateur est connecté
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
if (!userUuid) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Récupérer le profil utilisateur
|
||||
const userProfile = await userService.getUserByUuid(userUuid);
|
||||
|
||||
if (!userProfile) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les équipes pour la sélection
|
||||
const teams = await TeamsService.getTeams();
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<h1 className="text-3xl font-bold mb-8">Mon compte</h1>
|
||||
<AccountForm initialProfile={userProfile} teams={teams} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error loading account page:", error);
|
||||
redirect("/login");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user