shellphone.app/app/users/queries/get-current-user.ts
2021-08-08 12:34:29 +08:00

35 lines
662 B
TypeScript

import { Ctx } from "blitz";
import db from "db";
export default async function getCurrentUser(_ = null, { session }: Ctx) {
if (!session.userId) return null;
return db.user.findFirst({
where: { id: session.userId },
select: {
id: true,
name: true,
email: true,
role: true,
memberships: {
include: {
organization: {
select: {
id: true,
encryptionKey: true,
paddleCustomerId: true,
paddleSubscriptionId: true,
twilioAccountSid: true,
twilioAuthToken: true,
twilioApiKey: true,
twilioApiSecret: true,
twimlAppSid: true,
},
},
},
},
},
});
}