refactor: convert auth register to Server Action

- Add src/app/actions/auth.ts with registerUser
- Update RegisterForm to use Server Action
- Remove api/auth/register route
This commit is contained in:
2026-02-28 11:01:13 +01:00
parent b815202529
commit 7134c069d7
4 changed files with 33 additions and 72 deletions

23
src/app/actions/auth.ts Normal file
View File

@@ -0,0 +1,23 @@
"use server";
import { AuthServerService } from "@/lib/services/auth-server.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { AppError } from "@/utils/errors";
/**
* Inscrit un nouvel utilisateur
*/
export async function registerUser(
email: string,
password: string
): Promise<{ success: boolean; message: string }> {
try {
await AuthServerService.registerUser(email, password);
return { success: true, message: "Inscription réussie" };
} catch (error) {
if (error instanceof AppError) {
return { success: false, message: error.message };
}
return { success: false, message: "Erreur lors de l'inscription" };
}
}