fix: harden editorial registration flow
This commit is contained in:
1 parent
9b22752ef2
commit
a8d4e54ffb
8 files changed
+445
-109
No files matched your search
@@ -3,7 +3,10 @@ import { redirect } from "next/navigation";
|
||||
|
||||
import { env } from "@/config/env";
|
||||
import { registerEditorial } from "@/modules/auth/auth";
|
||||
import { RegistrationValidationError } from "@/modules/auth/registration";
|
||||
import {
|
||||
CURRENT_TERMS_VERSION,
|
||||
RegistrationValidationError,
|
||||
} from "@/modules/auth/registration";
|
||||
import {
|
||||
RegistrationForm,
|
||||
type RegistrationFormState,
|
||||
@@ -57,7 +60,7 @@ async function registerAction(
|
||||
countryCode: text(formData, "countryCode"),
|
||||
},
|
||||
actsForBusiness: formData.has("actsForBusiness"),
|
||||
termsVersion: formData.has("termsAccepted") ? text(formData, "termsVersion") : "",
|
||||
termsVersion: formData.has("termsAccepted") ? CURRENT_TERMS_VERSION : "",
|
||||
privacyAcknowledged: formData.has("privacyAcknowledged"),
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
import { toNextJsHandler } from "better-auth/next-js";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { auth } from "@/modules/auth/auth";
|
||||
|
||||
export const { GET, POST } = toNextJsHandler(auth);
|
||||
const handlers = toNextJsHandler(auth);
|
||||
|
||||
export const GET = handlers.GET;
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ all: string[] }> },
|
||||
): Promise<Response> {
|
||||
const { all } = await params;
|
||||
|
||||
if (all.join("/") === "sign-up/email") {
|
||||
return NextResponse.json(
|
||||
{ message: "Bitte verwenden Sie die Registrierung des Redaktionsportals." },
|
||||
{ status: 403 },
|
||||
);
|
||||
}
|
||||
|
||||
return handlers.POST(request);
|
||||
}
|
||||
Reference in new issue
Block a user