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:
23
src/app/actions/auth.ts
Normal file
23
src/app/actions/auth.ts
Normal 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" };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user