Aktueller Stand
This commit is contained in:
@@ -6,6 +6,7 @@ import { isAdminEmail, isSuperAdminEmail } from "../../../lib/auth";
|
||||
import { sendMail } from "../../../lib/mailer";
|
||||
import { checkRateLimit, getRateLimitConfig } from "../../../lib/rate-limit";
|
||||
import { getClientIp } from "../../../lib/request";
|
||||
import { getEmailVerificationRequired } from "../../../lib/system-settings";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const registrationSetting = await prisma.setting.findUnique({
|
||||
@@ -49,6 +50,9 @@ export async function POST(request: Request) {
|
||||
const passwordHash = await bcrypt.hash(password, 10);
|
||||
const superAdmin = isSuperAdminEmail(normalizedEmail);
|
||||
const admin = isAdminEmail(normalizedEmail) || superAdmin;
|
||||
const emailVerificationRequired = await getEmailVerificationRequired();
|
||||
const shouldVerifyEmail = emailVerificationRequired && !admin;
|
||||
const emailVerified = admin || !emailVerificationRequired;
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
@@ -57,7 +61,7 @@ export async function POST(request: Request) {
|
||||
passwordHash,
|
||||
role: superAdmin ? "SUPERADMIN" : admin ? "ADMIN" : "USER",
|
||||
status: admin ? "ACTIVE" : "PENDING",
|
||||
emailVerified: admin
|
||||
emailVerified
|
||||
}
|
||||
});
|
||||
|
||||
@@ -82,7 +86,7 @@ export async function POST(request: Request) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!admin) {
|
||||
if (shouldVerifyEmail) {
|
||||
const token = randomUUID();
|
||||
const expires = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
||||
await prisma.verificationToken.create({
|
||||
|
||||
Reference in New Issue
Block a user