Skip to content

Commit

Permalink
fix: company edit permissions are now validated correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Jan 12, 2024
1 parent 6c79001 commit e96dcf2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/Company/Edit/EditCompanyProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ export const EditCompanyController = () => {

const fields = useWatch({ control });

const shouldRevalidateEditingPermissions = useCallback(() => user?.isAdmin || user?.company?._id === id, [id, user]);
const shouldRevalidateEditingPermissions = useCallback(() => {

Check failure on line 135 in src/components/Company/Edit/EditCompanyProfileForm.js

View workflow job for this annotation

GitHub Actions / build

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return user?.isAdmin || user?.company?._id === id;
}, [id, user]);

const [canEdit, setCanEdit] = useState(undefined);

Expand Down Expand Up @@ -220,7 +222,7 @@ const EditCompanyProfileForm = ({ title }) => {

const Content = isMobile ? DialogContent : CardContent;

if (companyError || !canEdit) {
if (companyError || canEdit === false) {
return <Redirect {...redirectProps} />;
}

Expand Down

0 comments on commit e96dcf2

Please sign in to comment.