Files
sanihome/src/app/api/auth/register/route.ts
T
Alireza HassaniandCursor c53fb99330 Add shared customer auth, cart handoff, and account dropdown.
Mirror Meshkee customer sessions onto the storefront, continue checkout on the customer dashboard, and show profile/orders/admin links under the header name.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 16:41:00 +03:30

37 lines
1007 B
TypeScript

import { DOMAIN } from "@/lib/meshkee";
import { jsonResponse, meshkeeFetch } from "@/lib/meshkee-server";
export async function POST(request: Request) {
const body = await request.json().catch(() => null);
if (
!body?.cellNumber ||
!body?.password ||
!body?.firstName ||
!body?.lastName
) {
return jsonResponse({ error: "لطفاً همه فیلدهای الزامی را پر کنید" }, 400);
}
const res = await meshkeeFetch("/auth/register", {
method: "POST",
body: JSON.stringify({
cellNumber: body.cellNumber,
password: body.password,
firstName: body.firstName,
lastName: body.lastName,
email: body.email,
domain: DOMAIN,
acknowledgeExistingAccount: body.acknowledgeExistingAccount ?? false,
}),
});
if (!res.ok) {
return jsonResponse(
{ error: "ثبت‌نام ناموفق بود. اطلاعات را بررسی کنید." },
res.status,
);
}
return jsonResponse(res.data, 201);
}