Fixed Acc deleted Warnung im Profil
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import axios from "axios";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { DiscordAccount, prisma } from "@repo/db";
|
||||
import { prisma } from "@repo/db";
|
||||
import { getServerSession } from "../auth/[...nextauth]/auth";
|
||||
import { setStandardName } from "../../../helper/discord";
|
||||
import { getUserPenaltys } from "@repo/shared-components";
|
||||
@@ -52,8 +52,7 @@ export const GET = async (req: NextRequest) => {
|
||||
},
|
||||
});
|
||||
|
||||
const discordObject = {
|
||||
userId: session.user.id,
|
||||
const discordData = {
|
||||
accessToken: authData.access_token,
|
||||
refreshToken: authData.refresh_token,
|
||||
discordId: discordUser.id,
|
||||
@@ -63,12 +62,19 @@ export const GET = async (req: NextRequest) => {
|
||||
globalName: discordUser.global_name || discordUser.username,
|
||||
verified: discordUser.verified,
|
||||
tokenType: authData.token_type,
|
||||
} as DiscordAccount;
|
||||
};
|
||||
|
||||
await prisma.discordAccount.upsert({
|
||||
where: { discordId: discordUser.id },
|
||||
update: discordObject, // Updates if found
|
||||
create: discordObject, // Creates if not found
|
||||
update: discordData, // Updates if found
|
||||
create: {
|
||||
...discordData,
|
||||
User: {
|
||||
connect: {
|
||||
id: session.user.id,
|
||||
},
|
||||
},
|
||||
}, // Creates if not found
|
||||
});
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
|
||||
Reference in New Issue
Block a user