completed user admin page

This commit is contained in:
PxlLoewe
2025-03-15 11:09:55 -07:00
parent abf3475c7c
commit 37d02ea0bc
23 changed files with 567 additions and 106 deletions

View File

@@ -0,0 +1,35 @@
"use server";
import { PrismaClient } from "@prisma/client";
import { prisma, Prisma } from "@repo/db";
import bcrypt from "bcryptjs";
import { sendMailByTemplate } from "../../../../helper/mail";
export const editUser = async (id: string, data: Prisma.UserUpdateInput) => {
return await prisma.user.update({
where: {
id: id,
},
data,
});
};
export const resetPassword = async (id: string) => {
const password = Math.random().toString(36).slice(-8);
const hashedPassword = await bcrypt.hash(password, 15);
const user = await prisma.user.update({
where: {
id: id,
},
data: {
password: hashedPassword,
},
});
await sendMailByTemplate(user.email, "password-change", {
user: user,
password: password,
});
return { password };
};