protected async Task <bool> PermissionCheckAsync(NotificationDefinition notificationDefinition, Guid userId) { if (!notificationDefinition.PermissionName.IsNullOrEmpty()) { AuthorizationResult result; if (CurrentUser.Id == userId) { result = await AuthorizationService.AuthorizeAsync(notificationDefinition.PermissionName); } else { var userRoles = await NotificationStore.GetUserRoles(userId); var rolesClaims = userRoles.Select(ur => new Claim(AbpClaimTypes.Role, ur)).ToArray(); var claimsIdentity = new ClaimsIdentity(new Claim[] { new Claim(AbpClaimTypes.UserId, userId.ToString()), new Claim(AbpClaimTypes.TenantId, CurrentTenant.Id?.ToString()) }); claimsIdentity.AddClaims(rolesClaims); //Switch current user identity using (CurrentPrincipalAccessor.Change(new ClaimsPrincipal(claimsIdentity))) { result = await AuthorizationService.AuthorizeAsync(notificationDefinition.PermissionName); } } if (!result.Succeeded) { return(false); } } return(true); }
protected async Task <bool> FeatureCheckAsync(NotificationDefinition notificationDefinition) { if (notificationDefinition.FeatureName != null) { var result = await FeatureChecker.GetAsync(notificationDefinition.FeatureName, false); if (!result) { return(false); } } return(true); }