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,5 +1,6 @@
|
||||
import { getPool } from "./database";
|
||||
import { userService } from "./user-service";
|
||||
import { AuthService } from "./auth-service";
|
||||
import {
|
||||
UserEvaluation,
|
||||
UserProfile,
|
||||
@@ -121,7 +122,7 @@ export class EvaluationService {
|
||||
await client.query("BEGIN");
|
||||
|
||||
// 1. Upsert user avec UUID
|
||||
const userUuid = await userService.upsertUserUuid(evaluation.profile);
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
// 2. Upsert user_evaluation avec user_uuid
|
||||
const userEvalQuery = `
|
||||
@@ -413,7 +414,15 @@ export class EvaluationService {
|
||||
try {
|
||||
await client.query("BEGIN");
|
||||
|
||||
const userUuid = await userService.upsertUserUuid(profile);
|
||||
// Trouver l'utilisateur existant au lieu d'en créer un nouveau
|
||||
const existingUser = await userService.findUserByProfile(profile);
|
||||
if (!existingUser) {
|
||||
throw new Error(
|
||||
"Utilisateur non trouvé. Veuillez vous connecter avec votre email et mot de passe."
|
||||
);
|
||||
}
|
||||
|
||||
const userUuid = existingUser.uuid;
|
||||
|
||||
// Upsert user_evaluation avec user_uuid
|
||||
const userEvalResult = await client.query(
|
||||
@@ -609,7 +618,7 @@ export class EvaluationService {
|
||||
try {
|
||||
await client.query("BEGIN");
|
||||
|
||||
const userUuid = await userService.upsertUserUuid(profile);
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
// Supprimer directement la skill evaluation
|
||||
const deleteQuery = `
|
||||
|
||||
Reference in New Issue
Block a user