feat: user preferences (#470)
* wip: improve user preferences * wip: fix translations and add user danger zone * feat: add user delete button to danger zone * fix: test not working * refactor: add access checks for user edit page, improve not found behaviour, change user preference link in avatar menu to correct link * fix: remove invalid bg for container * chore: address pull request feedback
This commit is contained in:
@@ -41,6 +41,7 @@ const registrationSchemaApi = registrationSchema.and(
|
||||
);
|
||||
|
||||
const editProfileSchema = z.object({
|
||||
id: z.string(),
|
||||
name: usernameSchema,
|
||||
email: z
|
||||
.string()
|
||||
@@ -51,10 +52,20 @@ const editProfileSchema = z.object({
|
||||
.nullable(),
|
||||
});
|
||||
|
||||
const changePasswordSchema = z.object({
|
||||
userId: z.string(),
|
||||
password: passwordSchema,
|
||||
});
|
||||
const changePasswordSchema = z
|
||||
.object({
|
||||
previousPassword: z.string(),
|
||||
password: passwordSchema,
|
||||
confirmPassword: z.string(),
|
||||
})
|
||||
.refine((data) => data.password === data.confirmPassword, {
|
||||
path: ["confirmPassword"],
|
||||
message: "Passwords do not match",
|
||||
});
|
||||
|
||||
const changePasswordApiSchema = changePasswordSchema.and(
|
||||
z.object({ userId: z.string() }),
|
||||
);
|
||||
|
||||
export const userSchemas = {
|
||||
signIn: signInSchema,
|
||||
@@ -65,4 +76,5 @@ export const userSchemas = {
|
||||
password: passwordSchema,
|
||||
editProfile: editProfileSchema,
|
||||
changePassword: changePasswordSchema,
|
||||
changePasswordApi: changePasswordApiSchema,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user