make user full name mandatory

This commit is contained in:
m5r
2021-09-25 22:16:31 +08:00
parent 9d30930f96
commit 9cec49f255
8 changed files with 26 additions and 17 deletions

View File

@ -6,17 +6,17 @@ import notifyEmailChangeQueue from "../api/queue/notify-email-change";
const Body = z.object({
email: z.string().email(),
name: z.string(),
fullName: z.string(),
});
export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({ email, name }, ctx) => {
export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({ email, fullName }, ctx) => {
const user = await db.user.findFirst({ where: { id: ctx.session.userId! } });
if (!user) throw new NotFoundError();
const oldEmail = user.email;
await db.user.update({
where: { id: user.id },
data: { email, name },
data: { email, fullName },
});
if (oldEmail !== email) {