mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-09-30 04:33:11 +00:00
Adds a My Account page, reachable from the sidebar, with the signed-in user's read-only details and a Change Password section. The new password is checked live against the shared password rules (6+ characters, an uppercase letter, a number and a special character), which the invite registration flow reuses. The current password is still verified by the server first, and its rejection is shown on the current password field.
18 lines
631 B
TypeScript
18 lines
631 B
TypeScript
import { z } from "zod";
|
|
|
|
import { PASSWORDS_DO_NOT_MATCH_MESSAGE, passwordSchema } from "@/domain/auth/password-policy";
|
|
|
|
export const CURRENT_PASSWORD_INCORRECT_MESSAGE = "Current password is incorrect";
|
|
|
|
export const changePasswordSchema = z
|
|
.object({
|
|
currentPassword: z.string().min(1, "Current password is required"),
|
|
newPassword: passwordSchema,
|
|
confirmPassword: z.string(),
|
|
})
|
|
.refine((values) => values.newPassword === values.confirmPassword, {
|
|
path: ["confirmPassword"],
|
|
message: PASSWORDS_DO_NOT_MATCH_MESSAGE,
|
|
});
|
|
|
|
export type ChangePasswordFormValues = z.infer<typeof changePasswordSchema>;
|