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

34 lines
632 B
TypeScript
Raw Normal View History

2021-08-05 17:07:15 +00:00
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,
2021-08-05 17:07:15 +00:00
twimlAppSid: true,
},
},
},
},
},
});
}