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

Add MenuContributorBase to check permissions in advance. #7798

Closed
wants to merge 1 commit into from

Conversation

maliming
Copy link
Member

Resolve #7788

Usage:
Use GrantedPermissions to check the permissions.

public class TestMenuContributor1 : MenuContributorBase
{
    public TestMenuContributor1()
    {
        PreCheckPermissions.Add("MenuPermission1");
        PreCheckPermissions.Add("MenuPermission2");
    }

    public override Task ConfigureMenuAsync(MenuConfigurationContext context)
    {
        if (GrantedPermissions.Contains("MenuPermission1"))
        {
            //context.Menu.AddItem()
        }

        return Task.CompletedTask;
    }
}

@maliming maliming added this to the 4.3-preview milestone Feb 22, 2021
@maliming
Copy link
Member Author

@hikalkan
If you think this ok. I will do same changes to IToolbarContributor and apply to all modules and templates.

@hikalkan
Copy link
Member

This solution requires manual work and open to bugs (we may forget to add to the list). Also, it is a solution per menu contributor.

What if we add RequiredPermission to the ApplicationMenuItem. All contributors add menu items without permission checking. Then MenuManager removes items from the menu if user has no permission.
Same logic can be applied to toolbarcontributor.

@maliming maliming closed this Feb 22, 2021
@maliming maliming deleted the maliming/MenuContributorBase branch February 22, 2021 06:37
@maliming maliming removed this from the 4.3-preview milestone Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad performance Isgranted with redis
2 participants