You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
333 B
16 lines
333 B
2 years ago
|
import { Ctx } from "blitz"
|
||
|
import db from "db"
|
||
|
|
||
|
export default async function getCurrentUser(_ = null, { session }: Ctx) {
|
||
|
|
||
|
if (!session.userId) return null
|
||
|
|
||
|
const user = await db.user.findFirst({
|
||
|
where: { id: session.userId as number },
|
||
|
select: { id: true, name: true, email: true, role: true },
|
||
|
})
|
||
|
|
||
|
return user
|
||
|
|
||
|
}
|