mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 18:28:12 +00:00
Fix: Project roles
This commit is contained in:
@@ -106,7 +106,7 @@ const getUserProjectPermissions = async ({ workspaceId }: TGetUserProjectPermiss
|
|||||||
const { data } = await apiRequest.get<{
|
const { data } = await apiRequest.get<{
|
||||||
data: {
|
data: {
|
||||||
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
|
permissions: PackRule<RawRuleOf<MongoAbility<OrgPermissionSet>>>[];
|
||||||
membership: TProjectMembership;
|
membership: Omit<TProjectMembership, "roles"> & { roles: { role: string }[] };
|
||||||
};
|
};
|
||||||
}>(`/api/v1/workspace/${workspaceId}/permissions`, {});
|
}>(`/api/v1/workspace/${workspaceId}/permissions`, {});
|
||||||
|
|
||||||
@@ -121,6 +121,14 @@ export const useGetUserProjectPermissions = ({ workspaceId }: TGetUserProjectPer
|
|||||||
select: (data) => {
|
select: (data) => {
|
||||||
const rule = unpackRules<RawRuleOf<MongoAbility<ProjectPermissionSet>>>(data.permissions);
|
const rule = unpackRules<RawRuleOf<MongoAbility<ProjectPermissionSet>>>(data.permissions);
|
||||||
const ability = createMongoAbility<ProjectPermissionSet>(rule, { conditionsMatcher });
|
const ability = createMongoAbility<ProjectPermissionSet>(rule, { conditionsMatcher });
|
||||||
return { permission: ability, membership: data.membership };
|
|
||||||
|
const membership = {
|
||||||
|
...data.membership,
|
||||||
|
roles: data.membership.roles.map(({ role }) => {
|
||||||
|
return role;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
return { permission: ability, membership };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export type TProjectMembership = {
|
|||||||
createdAt: string;
|
createdAt: string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
roleId: string;
|
roles: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TWorkspaceUser = {
|
export type TWorkspaceUser = {
|
||||||
@@ -79,29 +79,29 @@ export type TWorkspaceUser = {
|
|||||||
organization: string;
|
organization: string;
|
||||||
roles: (
|
roles: (
|
||||||
| {
|
| {
|
||||||
id: string;
|
id: string;
|
||||||
role: "owner" | "admin" | "member" | "no-access" | "custom";
|
role: "owner" | "admin" | "member" | "no-access" | "custom";
|
||||||
customRoleId: string;
|
customRoleId: string;
|
||||||
customRoleName: string;
|
customRoleName: string;
|
||||||
customRoleSlug: string;
|
customRoleSlug: string;
|
||||||
isTemporary: false;
|
isTemporary: false;
|
||||||
temporaryRange: null;
|
temporaryRange: null;
|
||||||
temporaryMode: null;
|
temporaryMode: null;
|
||||||
temporaryAccessEndTime: null;
|
temporaryAccessEndTime: null;
|
||||||
temporaryAccessStartTime: null;
|
temporaryAccessStartTime: null;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
id: string;
|
id: string;
|
||||||
role: "owner" | "admin" | "member" | "no-access" | "custom";
|
role: "owner" | "admin" | "member" | "no-access" | "custom";
|
||||||
customRoleId: string;
|
customRoleId: string;
|
||||||
customRoleName: string;
|
customRoleName: string;
|
||||||
customRoleSlug: string;
|
customRoleSlug: string;
|
||||||
isTemporary: true;
|
isTemporary: true;
|
||||||
temporaryRange: string;
|
temporaryRange: string;
|
||||||
temporaryMode: string;
|
temporaryMode: string;
|
||||||
temporaryAccessEndTime: string;
|
temporaryAccessEndTime: string;
|
||||||
temporaryAccessStartTime: string;
|
temporaryAccessStartTime: string;
|
||||||
}
|
}
|
||||||
)[];
|
)[];
|
||||||
status: "invited" | "accepted" | "verified" | "completed";
|
status: "invited" | "accepted" | "verified" | "completed";
|
||||||
deniedPermissions: any[];
|
deniedPermissions: any[];
|
||||||
|
|||||||
Reference in New Issue
Block a user