feat(settings): restructure settings layout and separate route modules

This commit is contained in:
poyrazavsever
2026-07-20 10:25:40 +03:00
parent cc22c8ee1d
commit b424385667
34 changed files with 2867 additions and 1691 deletions
@@ -0,0 +1,43 @@
"use server";
import { headers } from "next/headers";
import { revalidatePath } from "next/cache";
import { auth } from "@/server/auth/auth";
import { requireFreelancerBackend } from "@/server/web/freelancer";
import { cleanText } from "@/server/web/form-data";
export async function changePasswordAction(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 requireFreelancerBackend();
await auth.api.changePassword({
headers: await headers(),
body: {
currentPassword,
newPassword,
revokeOtherSessions: true,
},
});
revalidatePath("/settings/security");
return { success: true };
} catch (error) {
console.error("Password change failed", error);
return { errorKey: "settings.security.errors.changeFailed" };
}
}