0
balessi75 created
ABP Commercial 7.4.2 / Blazor Server / EF / Non tiered / Separate Host and Tenant DBs / Lepton Theme
Hi,
Our custom SettingComponentContributor
is defined as below. What we are finding is that the ConfigureAsync
method executes, but the CheckPermissionsAsync
method never executes. The group shows in the UI without the permission check. Is there something we are misunderstanding when it comes to only showing a settings group if the current user has a certain permission?
Thanks in advance.
namespace FM.nVision.Blazor.Settings
{
public class NotificationSettingComponentContributor : ISettingComponentContributor
{
public Task ConfigureAsync(SettingComponentCreationContext context)
{
context.Groups.Add(
new SettingComponentGroup(
"FM.nVision.Settings",
"Email Notifications",
typeof(NotificationSettingGroupComponent), order: 8888
)
);
return Task.CompletedTask;
}
public async Task<bool> CheckPermissionsAsync(SettingComponentCreationContext context)
{
// check the permissions here
var authService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
if (await authService.IsGrantedAsync(nVisionPermissions.Notifications.Settings))
{
return true;
}
return false;
}
}
}
ConfigureServices
Configure<SettingManagementComponentOptions>(options =>
{
options.Contributors.Add(new NotificationSettingComponentContributor());
options.Contributors.Add(new AboutSettingComponentContributor());
});
2 Answer(s)
-
0
Hi,
you need to call
CheckPermissionsAsync
method yourself. -
0
That makes sense. Thanks @liangshiwei !!