mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-30 14:36:46 +00:00
Handle the roles better in the verify session
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { db, userOrgRoles } from "@server/db";
|
||||
import { db, roles, userOrgRoles } from "@server/db";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
|
||||
/**
|
||||
@@ -20,3 +20,17 @@ export async function getUserOrgRoleIds(
|
||||
);
|
||||
return rows.map((r) => r.roleId);
|
||||
}
|
||||
|
||||
export async function getUserOrgRoles(
|
||||
userId: string,
|
||||
orgId: string
|
||||
): Promise<{ roleId: number; roleName: string }[]> {
|
||||
const rows = await db
|
||||
.select({ roleId: userOrgRoles.roleId, roleName: roles.name })
|
||||
.from(userOrgRoles)
|
||||
.innerJoin(roles, eq(userOrgRoles.roleId, roles.roleId))
|
||||
.where(
|
||||
and(eq(userOrgRoles.userId, userId), eq(userOrgRoles.orgId, orgId))
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user