Fix: Check if credentials present
Fix: Request credentials as well
This commit is contained in:
parent
1e306ef1b0
commit
ce8cca8a39
2 changed files with 12 additions and 7 deletions
|
@ -46,18 +46,19 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
const result = await createEvent(currentUser.credentials[0], evt);
|
const result = await createEvent(currentUser.credentials[0], evt);
|
||||||
|
|
||||||
const hashUID = sha256(JSON.stringify(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({
|
await prisma.booking.create({
|
||||||
data: {
|
data: {
|
||||||
uid: hashUID,
|
uid: hashUID,
|
||||||
userId: currentUser.id,
|
userId: currentUser.id,
|
||||||
references: {
|
references: {
|
||||||
create: [
|
create: referencesToCreate
|
||||||
{
|
|
||||||
type: currentUser.credentials[0].type,
|
|
||||||
uid: result.id
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
eventTypeId: eventType.id,
|
eventTypeId: eventType.id,
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,11 @@ export default async function handler(req, res) {
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
user: true,
|
user: {
|
||||||
|
select: {
|
||||||
|
credentials: true
|
||||||
|
}
|
||||||
|
},
|
||||||
attendees: true,
|
attendees: true,
|
||||||
references: true
|
references: true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue