Fix: Check if credentials present

Fix: Request credentials as well
This commit is contained in:
nicolas 2021-06-07 09:18:41 +02:00
parent 1e306ef1b0
commit ce8cca8a39
2 changed files with 12 additions and 7 deletions

View file

@ -46,18 +46,19 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const result = await createEvent(currentUser.credentials[0], evt);
const hashUID = sha256(JSON.stringify(evt));
const referencesToCreate = currentUser.credentials.length == 0 ? [] : [
{
type: currentUser.credentials[0].type,
uid: result.id
}
];
await prisma.booking.create({
data: {
uid: hashUID,
userId: currentUser.id,
references: {
create: [
{
type: currentUser.credentials[0].type,
uid: result.id
}
]
create: referencesToCreate
},
eventTypeId: eventType.id,

View file

@ -11,7 +11,11 @@ export default async function handler(req, res) {
},
select: {
id: true,
user: true,
user: {
select: {
credentials: true
}
},
attendees: true,
references: true
}