Skip to content

Commit

Permalink
Merge pull request #389 from schuettloeffel-elsa/385-always-add-curre…
Browse files Browse the repository at this point in the history
…nt-user-to-acl

always add current user to acl
  • Loading branch information
ziegenberg committed May 29, 2024
2 parents ad384ff + 7173e68 commit e76eeb7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ const NewAccessPage = ({
// @ts-expect-error TS(7006): Parameter 'value' implicitly has an 'any' type.
const handleTemplateChange = async (value) => {
// fetch information about chosen template from backend
const template = await fetchAclTemplateById(value);
let template = await fetchAclTemplateById(value);

// always add current user to acl since template could lock the user out
template = template.concat({
role: user.userRole,
read: true,
write: true,
actions: [],
});

formik.setFieldValue("aclTemplate", value);
formik.setFieldValue("acls", template);
Expand Down
10 changes: 9 additions & 1 deletion src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ const ResourceDetailsAccessPolicyTab : React.FC <{
// @ts-expect-error TS(7006): Parameter 'templateId' implicitly has an 'any' typ... Remove this comment to see the full error message
const handleTemplateChange = async (templateId, setFormikFieldValue) => {
// fetch information about chosen template from backend
const template = await fetchAclTemplateById(templateId);
let template = await fetchAclTemplateById(templateId);

// always add current user to acl since template could lock the user out
template = template.concat({
role: user.userRole,
read: true,
write: true,
actions: [],
});

setFormikFieldValue("policies", template);
setFormikFieldValue("template", templateId);
Expand Down

0 comments on commit e76eeb7

Please sign in to comment.