Function
getClientAccess
({
userId,
clientId,
}: {
userId: string;
clientId: string;
})
Source from the content-addressed store, hash-verified
| 59 | ); |
| 60 | |
| 61 | export async function getClientAccess({ |
| 62 | userId, |
| 63 | clientId, |
| 64 | }: { |
| 65 | userId: string; |
| 66 | clientId: string; |
| 67 | }) { |
| 68 | const client = await db.client.findFirst({ |
| 69 | where: { |
| 70 | id: clientId, |
| 71 | }, |
| 72 | }); |
| 73 | |
| 74 | if (!client) { |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | if (client.projectId) { |
| 79 | return getProjectAccess({ userId, projectId: client.projectId }); |
| 80 | } |
| 81 | |
| 82 | if (client.organizationId) { |
| 83 | return getOrganizationAccess({ |
| 84 | userId, |
| 85 | organizationId: client.organizationId, |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | return false; |
| 90 | } |
Tested by
no test coverage detected