27 lines
605 B
TypeScript
27 lines
605 B
TypeScript
'use server';
|
|
import { Prisma, PrismaClient } from '@repo/db';
|
|
import { getServerSession } from '../../../api/auth/[...nextauth]/auth';
|
|
|
|
export const unlinkDiscord = async (userId: string) => {
|
|
const client = new PrismaClient();
|
|
await client.discordAccount.deleteMany({
|
|
where: {
|
|
userId,
|
|
},
|
|
});
|
|
};
|
|
|
|
export const updateUser = async (changes: Prisma.UserUpdateInput) => {
|
|
const session = await getServerSession();
|
|
if (!session) return null;
|
|
|
|
const client = new PrismaClient();
|
|
|
|
await client.user.update({
|
|
where: {
|
|
id: session.user.id,
|
|
},
|
|
data: changes,
|
|
});
|
|
};
|