mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 21:37:59 +00:00
feat: switched to root org id pattern
This commit is contained in:
@@ -25,10 +25,12 @@ import {
|
||||
TGetServiceTokenInfoDTO,
|
||||
TProjectServiceTokensDTO
|
||||
} from "./service-token-types";
|
||||
import { TOrgDALFactory } from "../org/org-dal";
|
||||
|
||||
type TServiceTokenServiceFactoryDep = {
|
||||
serviceTokenDAL: TServiceTokenDALFactory;
|
||||
userDAL: TUserDALFactory;
|
||||
orgDAL: Pick<TOrgDALFactory, "findById">;
|
||||
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
|
||||
projectEnvDAL: Pick<TProjectEnvDALFactory, "findBySlugs">;
|
||||
projectDAL: Pick<TProjectDALFactory, "findById">;
|
||||
@@ -45,7 +47,8 @@ export const serviceTokenServiceFactory = ({
|
||||
projectEnvDAL,
|
||||
projectDAL,
|
||||
accessTokenQueue,
|
||||
smtpService
|
||||
smtpService,
|
||||
orgDAL
|
||||
}: TServiceTokenServiceFactoryDep) => {
|
||||
const createServiceToken = async ({
|
||||
iv,
|
||||
@@ -184,7 +187,15 @@ export const serviceTokenServiceFactory = ({
|
||||
if (!isMatch) throw new UnauthorizedError({ message: "Invalid service token" });
|
||||
await accessTokenQueue.updateServiceTokenStatus(serviceToken.id);
|
||||
|
||||
return { ...serviceToken, lastUsed: new Date(), orgId: project.orgId };
|
||||
const serviceTokenOrgDetails = await orgDAL.findById(project.orgId);
|
||||
|
||||
return {
|
||||
...serviceToken,
|
||||
lastUsed: new Date(),
|
||||
orgId: project.orgId,
|
||||
parentOrgId: serviceTokenOrgDetails.parentOrgId || serviceTokenOrgDetails.id,
|
||||
rootOrgId: serviceTokenOrgDetails.rootOrgId || serviceTokenOrgDetails.id
|
||||
};
|
||||
};
|
||||
|
||||
const notifyExpiringTokens = async () => {
|
||||
|
||||
Reference in New Issue
Block a user