Added redemptions & redeemable actions. Fixed a few bugs.
This commit is contained in:
@ -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: {
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user