entitlementsBE
This commit is contained in:
1 parent
86ce30b5f4
commit
c43241eb52
13 files changed
+319
-5
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { OrgMembership, TeamMembership, IRole } from "@/db/models/index.js";
|
||||
import ApiError from "@/utils/ApiError.js";
|
||||
|
||||
import { EntitlementsFactory } from "@/services/system/EntitlementsService.js";
|
||||
import type { Entitlements } from "@/types/entitlements.js";
|
||||
import { getChildLogger } from "@/logger/Logger.js";
|
||||
const logger = getChildLogger("AddUserContext");
|
||||
interface IRolesObj {
|
||||
orgRole?: IRole;
|
||||
teamRole: IRole;
|
||||
@@ -145,6 +148,11 @@ export const addUserContext = async (
|
||||
};
|
||||
req.user.currentTeamId = currentTeamId;
|
||||
|
||||
// Attach entitlements for the org
|
||||
const provider = EntitlementsFactory.create();
|
||||
const entitlements: Entitlements = await provider.getForOrg(orgId);
|
||||
req.entitlements = entitlements;
|
||||
|
||||
return next();
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
||||
Reference in new issue
Block a user