feat: add change password form (#199)

This commit is contained in:
Manuel
2024-03-06 21:20:41 +01:00
committed by GitHub
parent c0401702f0
commit beb7defd32
6 changed files with 117 additions and 8 deletions

View File

@@ -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 (