mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-08 06:42:39 +02:00
dry refactor
This commit is contained in:
parent
6adf1e8e42
commit
97fad8633f
3 changed files with 9 additions and 35 deletions
|
|
@ -13,21 +13,23 @@ import { Project } from "../lib/types/project_types";
|
|||
import { USE_AUTH } from "../lib/feature_flags";
|
||||
import { authorizeUserAction } from "./billing_actions";
|
||||
import { Workflow } from "../lib/types/workflow_types";
|
||||
import { container } from "@/di/container";
|
||||
import { IProjectActionAuthorizationPolicy } from "@/src/application/policies/project-action-authorization.policy";
|
||||
|
||||
const KLAVIS_API_KEY = process.env.KLAVIS_API_KEY || '';
|
||||
|
||||
const projectActionAuthorizationPolicy = container.resolve<IProjectActionAuthorizationPolicy>('projectActionAuthorizationPolicy');
|
||||
|
||||
export async function projectAuthCheck(projectId: string) {
|
||||
if (!USE_AUTH) {
|
||||
return;
|
||||
}
|
||||
const user = await authCheck();
|
||||
const membership = await projectMembersCollection.findOne({
|
||||
projectId,
|
||||
await projectActionAuthorizationPolicy.authorize({
|
||||
caller: 'user',
|
||||
userId: user._id,
|
||||
projectId,
|
||||
});
|
||||
if (!membership) {
|
||||
throw new Error('User not a member of project');
|
||||
}
|
||||
}
|
||||
|
||||
async function createBaseProject(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue