feat: add change password form (#199)
This commit is contained in:
@@ -87,6 +87,18 @@ export const userRouter = createTRPCRouter({
|
||||
delete: publicProcedure.input(z.string()).mutation(async ({ input, ctx }) => {
|
||||
await ctx.db.delete(users).where(eq(users.id, input));
|
||||
}),
|
||||
changePassword: publicProcedure
|
||||
.input(validation.user.changePassword)
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
const salt = await createSalt();
|
||||
const hashedPassword = await hashPassword(input.password, salt);
|
||||
await ctx.db
|
||||
.update(users)
|
||||
.set({
|
||||
password: hashedPassword,
|
||||
})
|
||||
.where(eq(users.id, input.userId));
|
||||
}),
|
||||
});
|
||||
|
||||
const createUser = async (
|
||||
|
||||
@@ -585,6 +585,17 @@ export default {
|
||||
},
|
||||
security: {
|
||||
title: "Security",
|
||||
changePassword: {
|
||||
title: "Change password",
|
||||
form: {
|
||||
password: {
|
||||
label: "Password",
|
||||
},
|
||||
},
|
||||
message: {
|
||||
passwordUpdated: "Updated password",
|
||||
},
|
||||
},
|
||||
},
|
||||
dangerZone: {
|
||||
title: "Danger zone",
|
||||
|
||||
@@ -33,10 +33,16 @@ const editProfileSchema = z.object({
|
||||
.nullable(),
|
||||
});
|
||||
|
||||
const changePasswordSchema = z.object({
|
||||
userId: z.string(),
|
||||
password: passwordSchema,
|
||||
});
|
||||
|
||||
export const userSchemas = {
|
||||
signIn: signInSchema,
|
||||
init: initUserSchema,
|
||||
create: createUserSchema,
|
||||
password: passwordSchema,
|
||||
editProfile: editProfileSchema,
|
||||
changePassword: changePasswordSchema,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user