var controlNumbersReport = pages.CreateChildPermission(AppPermissions.Pages_ControlNumbersReport, L("ControlNumbersReport"), multiTenancySides: MultiTenancySides.Tenant);
public const string Pages_ControlNumbersReport = "Pages.ControlNumbersReport";
using Echonos.Authorization;
[AllowAnonymous]
public async Task<ActionResult> GetLogo(int? tenantId)
{
}
using Abp.Authorization;
using Echonos.Authorization;
[AbpAuthorize(AppPermissions.Pages_ControlNumbers)]
public class ControlNumbersAppService : EchonosAppServiceBase, IControlNumbersAppService {
public void CreateUser(CreateOrUpdateUserInput input)
{
if (!PermissionChecker.IsGranted("Administration.UserManagement.CreateUser"))
{
throw new AbpAuthorizationException("You are not authorized to create user!");
}
//A user can not reach this point if he is not granted for "Administration.UserManagement.CreateUser" permission.
PermissionChecker.Authorize("Administration.UserManagement.CreateUser");
//A user can not reach this point if he is not granted for "Administration.UserManagement.CreateUser" permission.
}
}
}
User user = GetCurrentUser();
var currentUserRoleNames = await UserManager.GetRolesAsync(GetCurrentUser()).ToArray();
Tenant tenant = GetCurrentTenant();
const isPartner = abp.auth.isGranted("Pages.Partner");
<div class="col-md-3" [hidden]="!isGrantedAny('Pages.Partner')">
<a href="javascript:;" *ngIf="permission.isGranted('Pages.ControlNumbers.Delete')"
(click)="deleteControlNumber(record.controlNumber)">{{l('Delete')}}</a>
<button *ngIf="'Pages.Administration.WebhookSubscription.Create' | permission">
var currentUser = await GetCurrentUserAsync();
var userInAdminRoles =
await UserManager.IsInRoleAsync(currentUser, StaticRoleNames.Tenants.HQAdmin) ||
await UserManager.IsInRoleAsync(currentUser, StaticRoleNames.Tenants.HQInternal) ||
await UserManager.IsInRoleAsync(currentUser, StaticRoleNames.Tenants.Admin);
// ---------------- //
namespace Nudyne.Star.Authorization.Roles
{
public static class StaticRoleNames
{
public static class Host
{
public const string Admin = "Admin";
}
public static class Tenants
{
public const string Admin = "Admin";
public const string User = "User";
// custom roles are added here
public const string RepRegular = "Regular";
public const string RepSupervisor = "Supervisor";
}
}
}
Where TenancyName = 'CNE'
Result => TenantId = 2
Where TenantId = 2 And Username = 'admin'
Result => UserId = 6
Where TenantId = 2 And (Name = 'User' Or Name = 'Admin')
Result => RoleId = 4 (Admin), 5 (User)
Where UserId = 6
Result => RoleId = 4 (Admin), 5 (User)
User Role Needs to have the RolePermissionSetting for Pages.Provider as IsGranted = 1.
Both Roles (Admin and User) should not have IsGranted as 1.
Where (RoleId = 4 Or RoleId = 5) And (Name = 'Pages' Or Name = 'Pages.Provider' Or Name = 'Pages.Partner')
Result =>
Id | CreationTime | CreatorUserId | Discriminator | IsGranted | Name | TenantId | RoleId | UserId |
---|---|---|---|---|---|---|---|---|
85 | 2019-10-22 00:25:38 | 6 | RolePermissionSetting | 0 | Pages.Partner | 2 | 4 | |
100 | 2019-10-25 00:47:16 | 6 | RolePermissionSetting | 0 | Pages.Provider | 2 | 4 | |
102 | 2019-10-25 00:47:46 | 6 | RolePermissionSetting | 1 | Pages.Provider | 2 | 5 | |
103 | 2019-10-25 00:47:47 | 6 | RolePermissionSetting | 1 | Pages | 2 | 5 |
Same logic as above reversed.
Notice that the only thing that changes is the Id 102
, Name
column.
Id | CreationTime | CreatorUserId | Discriminator | IsGranted | Name | TenantId | RoleId | UserId |
---|---|---|---|---|---|---|---|---|
85 | 2019-10-22 00:25:38 | 6 | RolePermissionSetting | 0 | Pages.Partner | 2 | 4 | |
100 | 2019-10-25 00:47:16 | 6 | RolePermissionSetting | 0 | Pages.Provider | 2 | 4 | |
102 | 2019-10-25 00:47:46 | 6 | RolePermissionSetting | 1 | Pages.Partner | 2 | 5 | |
103 | 2019-10-25 00:47:47 | 6 | RolePermissionSetting | 1 | Pages | 2 | 5 |
var currentUserRoleNames = UserManager.GetRolesAsync(GetCurrentUser()).Result.ToArray();