Base solution for your next web application
Open Closed

Overriding permissions #9146


User avatar
0
acmeware created

Hi, I need to create a method to override certain permissions regardless of what is in the table.

In my UserManager.cs I added this hard-code to test out where to do this. It is not working, the user still has permission to this page. Where should I override permissions in this way if not here?

public override async Task<bool> IsGrantedAsync(long userId, Permission permission)
{
    if (permission.Name == "Pages.ConnectionLogs.Create")
    {
        return false;
    }
    return await base.IsGrantedAsync(userId, permission);                     
}

2 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    Please try to override the synchronization method at the same time

    public virtual bool IsGranted(long userId, Permission permission)
    
  • User Avatar
    0
    acmeware created

    Perfect. Thanks!