Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Resource manager permissions not being saved properly #6045

Closed
2 tasks done
Adeoluwa-Simeon opened this issue May 22, 2024 · 5 comments · Fixed by #6046
Closed
2 tasks done

[Bug]: Resource manager permissions not being saved properly #6045

Adeoluwa-Simeon opened this issue May 22, 2024 · 5 comments · Fixed by #6046

Comments

@Adeoluwa-Simeon
Copy link

Adeoluwa-Simeon commented May 22, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

On attempting to save permissions from the resource manager there are 3 issues:

  1. Updated permissions do not reflect on the UI after they are saved
  2. The saved permissions do not always update the right details in the database
  3. Extra permissions (Asides read, browse, write) do not save when the write permission is checked

Steps to reproduce?

1st issue

  1. Access the menu Persona Bar > Manage > Global Assets

  2. Right-click the Templates folder > Edit > Go to the Permissions tab

  3. Add the "Write to folder" permission to "registered users" and save
    image

  4. Right-click the Templates folder > Edit > Go to the Permissions
    image
    Note that updated permissions do not reflect on the UI

  5. Check the data in the db, there should be records saved
    image

2nd issue

  1. Access the menu Persona Bar > Manage > Global Assets

  2. Right-click the Templates folder > Edit > Go to the Permissions tab

  3. Deny the "View Folder" permission then Add the "Browse Folder" permission and then save
    image

  4. Check the data is saved in the db, it does not reflect the UI, as all reflect as AllowAccess=0, while one of them should be AllowAccess=1
    image

3rd issue

  1. Add an extra permission to the permissions table on the database, you can use this query
    INSERT INTO [dbo].[Permission]([PermissionCode],[ModuleDefID],[PermissionKey],[PermissionName],[ViewOrder]) VALUES ('SYSTEM_FOLDER',-1,'COPY','Copy',1)

  2. Restart the app on iis to reload the cache

  3. Access the menu Persona Bar > Manage > Global Assets

  4. Right-click the Templates folder > Edit > Go to the Permissions tab

  5. Add all permissions and save
    image

  6. Check the data is saved in the db, it does not reflect the UI, as only 3 permissions are saved, instead of 4
    image

Current Behavior

Permissions not being saved properly and not being shown when saved

Expected Behavior

Permissions being saved properly and shown when saved

Relevant log output

No response

Anything else?

No response

Affected Versions

9.13.3 (latest release)

What browsers are you seeing the problem on?

Chrome

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Adeoluwa-Simeon
Copy link
Author

I would like to work on a fix for this issue, I already have a fix ready to go, so ETA can be an hour

@jeremy-farrance
Copy link
Contributor

jeremy-farrance commented May 22, 2024

This has some (obvious?) overlap with #5857, "[Bug]: Resource Manager Error: cannot Remove Permissions on Folders" that I posted with a lot of details and easy to reproduce steps in Nov, 2023.

@Adeoluwa-Simeon
Copy link
Author

Adeoluwa-Simeon commented May 22, 2024

@jeremy-farrance You are right it does, I assumed from the title and did not check to see that you reported saving issue as well.
While I have a PR to fix what I have reported, do I need to do change anything?

@Adeoluwa-Simeon
Copy link
Author

Adeoluwa-Simeon commented May 22, 2024

Root Cause

  1. For the first issue with not returning valid permissions from the Database, the issue is with the [dbo].[GetFolderPermissionsByPortalAndPath] looking for a default -1 value for the PortalId field in the view dbo.[vw_FolderPermissions]

CREATE PROCEDURE [dbo].[GetFolderPermissionsByPortalAndPath]
@portalid int,
@FolderPath nvarchar(300)
AS
BEGIN
SET @portalid = IsNull(@portalid, -1)

SELECT *
FROM   dbo.[vw_FolderPermissions]
WHERE  PortalID = @PortalId AND (FolderPath = @FolderPath OR @FolderPath IS NULL)

END

But the view dbo.[vw_FolderPermissions] provides null as the value for PortalId for these saved permissions. And then when permissions are saved, it would not load the saved permissions on the UI.

  1. For the other 2 issues, they are from the front-end, there is an adjustRelatedPermissions function used to trigger some permissions on and off when a particular permission is selected.

Example: when 'Read' is disabled, both 'Browse' and 'Write to folder' are disabled if enabled previously.
This is called when a new selection is made and right before saving the records, the problem is:

  • It does not keep track of new selections and applies the same rules to whatever check boxes are checked, such that if the rules state, when 'Read' is disabled 'Write to Folder' must be disabled and when 'Write to Folder' is enabled, 'Read' must be enabled. If we enter a disabled 'Read' first and try to enable 'Write to Folder', both rules get applied at the same time and 'Read' stays disabled, and 'Write to Folder' may appear to be enabled but actually submits as disabled.
  • Whenever write is selected only 'Read', 'Browse' and 'Write to Folder' can be submitted.

This causes the view and saved data discrepancies.

Fix

  1. Update dbo.[vw_FolderPermissions] to provide a default value -1 for portalID if it is null
    image

  2. Fixed the adjustRelatedPermissions function to work properly, taking note of the new permissions and applying the adjustments also allowing other permissions save when the 'Write to Folder' is allowed.

Submitted a PR -#6046

@valadas
Copy link
Contributor

valadas commented Jun 20, 2024

#5857 has some similarities but must be slightly different issue as #6046 does fix everything mentioned here but not the other issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants