feat(i18n): localize portal account settings

This commit is contained in:
poyrazavsever
2026-07-21 13:37:23 +03:00
parent 48f9d7bc87
commit 86a9c79511
11 changed files with 397 additions and 40 deletions
+43
View File
@@ -0,0 +1,43 @@
"use server";
import { headers } from "next/headers";
import { revalidatePath } from "next/cache";
import { auth } from "@/server/auth/auth";
import { requirePortalBackend } from "@/server/web/portal";
import { cleanText } from "@/server/web/form-data";
export async function changePortalPasswordAction(formData: FormData) {
const currentPassword = cleanText(formData.get("currentPassword")) ?? "";
const newPassword = cleanText(formData.get("newPassword")) ?? "";
const confirmPassword = cleanText(formData.get("confirmPassword")) ?? "";
if (!currentPassword) {
return { errorKey: "settings.security.errors.currentRequired" };
}
if (newPassword.length < 8 || newPassword.length > 128) {
return { errorKey: "settings.security.errors.newLength" };
}
if (newPassword !== confirmPassword) {
return { errorKey: "settings.security.errors.confirmMismatch" };
}
if (newPassword === currentPassword) {
return { errorKey: "settings.security.errors.samePassword" };
}
try {
await requirePortalBackend();
await auth.api.changePassword({
headers: await headers(),
body: {
currentPassword,
newPassword,
revokeOtherSessions: true,
},
});
revalidatePath("/portal/settings/security");
return { success: true };
} catch (error) {
console.error("Portal password change failed", error);
return { errorKey: "settings.security.errors.changeFailed" };
}
}