Added redemptions & redeemable actions. Fixed a few bugs.

This commit is contained in:
Tom
2024-06-24 22:16:55 +00:00
parent 68df045c54
commit 6548ce33e0
35 changed files with 1787 additions and 471 deletions

View File

@ -12,7 +12,7 @@ export default async function fetchUserWithImpersonation(req: Request) {
}
const token = req.headers?.get('x-api-key')
if (token === null || token === undefined)
if (!token)
return null
const key = await db.apiKey.findFirst({
@ -21,7 +21,8 @@ export default async function fetchUserWithImpersonation(req: Request) {
}
})
if (!key) return null
if (!key)
return null
return fetch(key.userId)
}
@ -35,6 +36,7 @@ const fetch = async (userId: string) => {
if (!user) return null
// Only admins can impersonate others.
if (user.role == "ADMIN") {
const impersonation = await db.impersonation.findFirst({
where: {

View File

@ -12,7 +12,7 @@ export default async function fetchUser(req: Request) {
}
const token = req.headers?.get('x-api-key')
if (token === null || token === undefined)
if (!token)
return null
const key = await db.apiKey.findFirst({
@ -38,6 +38,6 @@ const fetch = async (userId: string) => {
return {
id: user.id,
username: user.name,
role: user.role
role: user.role,
}
}