resolve pr review issues

This commit is contained in:
Tuan Dang
2024-07-18 10:32:39 +07:00
parent ada0033bd0
commit 498b1109c9
5 changed files with 16 additions and 15 deletions
@@ -186,7 +186,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
}) })
} }
}, },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]), onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => { handler: async (req) => {
if (req.auth.actor !== ActorType.USER) return; if (req.auth.actor !== ActorType.USER) return;
@@ -289,7 +289,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
}) })
} }
}, },
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]), onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => { handler: async (req) => {
const memberships = await server.services.org.listProjectMembershipsByOrgMembershipId({ const memberships = await server.services.org.listProjectMembershipsByOrgMembershipId({
actor: req.permission.type, actor: req.permission.type,
+5 -4
View File
@@ -379,6 +379,11 @@ export const orgServiceFactory = ({
const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId); const { permission } = await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId);
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member); ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
const [foundMembership] = await orgDAL.findMembership({ id: membershipId, orgId });
if (!foundMembership) throw new NotFoundError({ message: "Failed to find organization membership" });
if (foundMembership.userId === userId)
throw new BadRequestError({ message: "Cannot update own organization membership" });
const isCustomRole = !Object.values(OrgMembershipRole).includes(role as OrgMembershipRole); const isCustomRole = !Object.values(OrgMembershipRole).includes(role as OrgMembershipRole);
if (role && isCustomRole) { if (role && isCustomRole) {
const customRole = await orgRoleDAL.findOne({ slug: role, orgId }); const customRole = await orgRoleDAL.findOne({ slug: role, orgId });
@@ -400,10 +405,6 @@ export const orgServiceFactory = ({
return membership; return membership;
} }
if (isActive !== undefined) {
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Delete, OrgPermissionSubjects.Member);
}
const [membership] = await orgDAL.updateMembership({ id: membershipId, orgId }, { role, roleId: null, isActive }); const [membership] = await orgDAL.updateMembership({ id: membershipId, orgId }, { role, roleId: null, isActive });
return membership; return membership;
}; };
@@ -25,7 +25,7 @@ export const DeleteActionModal = ({
deleteKey, deleteKey,
onDeleteApproved, onDeleteApproved,
title, title,
subTitle = "This action is irreversible!", subTitle = "This action is irreversible.",
buttonText = "Delete" buttonText = "Delete"
}: Props): JSX.Element => { }: Props): JSX.Element => {
const [inputData, setInputData] = useState(""); const [inputData, setInputData] = useState("");
@@ -86,7 +86,7 @@ export const DeleteActionModal = ({
<FormControl <FormControl
label={ label={
<div className="break-words pb-2 text-sm"> <div className="break-words pb-2 text-sm">
Type <span className="font-bold">{deleteKey}</span> to delete the resource Type <span className="font-bold">{deleteKey}</span> to perform this action
</div> </div>
} }
className="mb-0" className="mb-0"
@@ -94,7 +94,7 @@ export const DeleteActionModal = ({
<Input <Input
value={inputData} value={inputData}
onChange={(e) => setInputData(e.target.value)} onChange={(e) => setInputData(e.target.value)}
placeholder="Type to delete..." placeholder="Type confirm..."
/> />
</FormControl> </FormControl>
</form> </form>
@@ -1,6 +1,6 @@
import { useCallback, useMemo, useState } from "react"; import { useCallback, useMemo, useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { faEllipsis,faMagnifyingGlass, faUsers } from "@fortawesome/free-solid-svg-icons"; import { faEllipsis, faMagnifyingGlass, faUsers } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
+5 -5
View File
@@ -25,7 +25,7 @@ import {
} from "@app/hooks/api"; } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp"; import { usePopUp } from "@app/hooks/usePopUp";
import { UserDetailsSection, UserOrgMembershipModal,UserProjectsSection } from "./components"; import { UserDetailsSection, UserOrgMembershipModal, UserProjectsSection } from "./components";
export const UserPage = withPermission( export const UserPage = withPermission(
() => { () => {
@@ -161,9 +161,9 @@ export const UserPage = withPermission(
: "" : ""
} }
onClick={async () => { onClick={async () => {
if (currentOrg?.authEnforced) { if (currentOrg?.scimEnabled) {
createNotification({ createNotification({
text: "You cannot manage users from Infisical when org-level auth is enforced for your organization", text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
type: "error" type: "error"
}); });
return; return;
@@ -204,9 +204,9 @@ export const UserPage = withPermission(
: "pointer-events-none cursor-not-allowed opacity-50" : "pointer-events-none cursor-not-allowed opacity-50"
)} )}
onClick={() => { onClick={() => {
if (currentOrg?.authEnforced) { if (currentOrg?.scimEnabled) {
createNotification({ createNotification({
text: "You cannot manage users from Infisical when org-level auth is enforced for your organization", text: "You cannot manage users from Infisical when SCIM is enabled for your organization",
type: "error" type: "error"
}); });
return; return;