refactor: update authentication flow and cookie management
- Changed COOKIE_NAME from "peakSkills_userId" to "session_token" for better clarity. - Updated AuthClient to handle login and registration with new data structures. - Enhanced AuthWrapper to manage user sessions and display appropriate messages. - Added error handling in LoginForm and RegisterForm for better user feedback. - Refactored user service methods to streamline user creation and verification processes.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { TeamsService, userService } from "@/services";
|
||||
import { AuthService } from "@/services";
|
||||
import { LoginLayout, AuthWrapper, LoginLoading } from "@/components/login";
|
||||
@@ -11,20 +10,17 @@ export default async function LoginPage() {
|
||||
// Vérifier si l'utilisateur est déjà connecté
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
let userProfile = null;
|
||||
|
||||
if (userUuid) {
|
||||
// Si l'utilisateur est connecté, récupérer son profil côté serveur
|
||||
const userProfile = await userService.getUserByUuid(userUuid);
|
||||
|
||||
if (userProfile) {
|
||||
// Rediriger vers l'accueil si déjà connecté
|
||||
redirect("/");
|
||||
}
|
||||
userProfile = await userService.getUserByUuid(userUuid);
|
||||
}
|
||||
|
||||
// Si l'utilisateur n'est pas connecté, afficher le formulaire d'auth
|
||||
return (
|
||||
<LoginLayout>
|
||||
<AuthWrapper teams={teams} />
|
||||
<AuthWrapper teams={teams} initialUser={userProfile} />
|
||||
</LoginLayout>
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user