shellphone.app/app/users/queries/get-current-user.ts

34 lines
632 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,
twilioApiKey: true,
twilioApiSecret: true,
twimlAppSid: true,
},
},
},
},
},
});
}