Skip to content

Commit

Permalink
fix: project accesss (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored May 25, 2024
1 parent 680bd1c commit c43b6c6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/backend/src/utils/authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import sql from "./db"
import Context from "./koa"
import { Action, ResourceName, hasAccess } from "shared"

// TODO: Needs to use account_project instead
export async function checkProjectAccess(projectId: string, userId: string) {
const [{ exists: hasAccess }] = await sql`
select exists (
select 1
from project
where org_id = (select org_id from account where id = ${userId})
and id = ${projectId}
from account_project ap
where ap.project_id = ${projectId} and ap.account_id = ${userId}
)
`
`
return hasAccess
}

Expand Down

0 comments on commit c43b6c6

Please # to comment.