Exemple #1
0
    private async Task SaveAsync()
    {
        try
        {
            var updateDto = new UpdatePermissionsDto
            {
                Permissions = _groups
                              .SelectMany(g => g.Permissions)
                              .Select(p => new UpdatePermissionDto {
                    IsGranted = p.IsGranted, Name = p.Name
                })
                              .ToArray()
            };

            await PermissionAppService.UpdateAsync(_providerName, _providerKey, updateDto);

            await CurrentApplicationConfigurationCacheResetService.ResetAsync();

            await InvokeAsync(_modal.Hide);
        }
        catch (Exception ex)
        {
            await HandleErrorAsync(ex);
        }
    }
Exemple #2
0
    private async Task SaveAsync()
    {
        try
        {
            var updateDto = new UpdatePermissionsDto
            {
                Permissions = _groups
                              .SelectMany(g => g.Permissions)
                              .Select(p => new UpdatePermissionDto {
                    IsGranted = p.IsGranted, Name = p.Name
                })
                              .ToArray()
            };

            if (!updateDto.Permissions.Any(x => x.IsGranted))
            {
                if (!await Message.Confirm(L["RemoveAllPermissionsWarningMessage"].Value))
                {
                    return;
                }
            }

            await PermissionAppService.UpdateAsync(_providerName, _providerKey, updateDto);

            await CurrentApplicationConfigurationCacheResetService.ResetAsync();

            await InvokeAsync(_modal.Hide);
        }
        catch (Exception ex)
        {
            await HandleErrorAsync(ex);
        }
    }
Exemple #3
0
    public virtual async Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
    {
        await CheckProviderPolicy(providerName);

        foreach (var permissionDto in input.Permissions)
        {
            await PermissionManager.SetAsync(permissionDto.Name, providerName, providerKey, permissionDto.IsGranted);
        }
    }
 public virtual async Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
 {
     await RequestAsync(nameof(UpdateAsync), new ClientProxyRequestTypeValue
     {
         { typeof(string), providerName },
         { typeof(string), providerKey },
         { typeof(UpdatePermissionsDto), input }
     });
 }
Exemple #5
0
        private async Task SaveAsync()
        {
            var updateDto = new UpdatePermissionsDto
            {
                Permissions = _groups
                              .SelectMany(g => g.Permissions)
                              .Select(p => new UpdatePermissionDto {
                    IsGranted = p.IsGranted, Name = p.Name
                })
                              .ToArray()
            };

            await PermissionAppService.UpdateAsync(_providerName, _providerKey, updateDto);

            _modal.Hide();
        }
        public async Task <IActionResult> OnPostAsync()
        {
            updatedPermissionsDto = new UpdatePermissionsDto();
            foreach (var group in permissionGroupDto)
            {
                foreach (var perItem in group.Permissions)
                {
                    UpdatePermissionDto item = new UpdatePermissionDto();
                    item.Name      = perItem.Name;
                    item.IsGranted = perItem.IsGranted;
                    updatedPermissionsDto.Permissions.Add(item);
                }
            }

            await permissionAppService.UpdatePermissionAsync(ProviderName, ProviderKey, updatedPermissionsDto);

            return(Page());
        }
        public async Task UpdatePermissionsAsync(Guid id, UpdatePermissionsDto input)
        {
            var role = await _roleRepository.GetAsync(id);

            await _permissionAppServiceHelper.UpdateAsync(RolePermissionValueProvider.ProviderName, role.Name, input);
        }
Exemple #8
0
 public virtual Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
 {
     return(_permissionService.UpdateAsync(providerName, providerKey, input));
 }
 public async Task UpdatePermissionsAsync(Guid id, UpdatePermissionsDto input)
 {
     await _permissionAppServiceHelper.UpdateAsync(UserPermissionValueProvider.ProviderName, id.ToString(), input);
 }
        public virtual async Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
        {
            await CheckProviderPolicy(providerName);

            var permissions = await PermissionGrantRepository.GetListAsync(providerName, providerKey);

            foreach (var permission in input.Permissions)
            {
                var editPermission = permissions.FirstOrDefault(p => p.Name.Equals(permission.Name));
                if (editPermission == null)
                {
                    if (permission.IsGranted)
                    {
                        var permissionGrant = new PermissionGrant(GuidGenerator.Create(),
                                                                  permission.Name, providerName, providerKey, CurrentTenant.Id);
                        await PermissionGrantRepository.InsertAsync(permissionGrant);
                    }
                }
                else
                {
                    if (!permission.IsGranted)
                    {
                        await PermissionGrantRepository.DeleteAsync(editPermission.Id);
                    }
                }
            }
        }
Exemple #11
0
 public virtual Task UpdatePermissionsAsync(Guid id, UpdatePermissionsDto input)
 {
     return(_roleAppService.UpdatePermissionsAsync(id, input));
 }
Exemple #12
0
        public virtual async Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
        {
            switch (providerName)
            {
            case UserPermissionValueProvider.ProviderName:
                await _userAppService.UpdatePermissionsAsync(Guid.Parse(providerKey), input);

                break;

            case RolePermissionValueProvider.ProviderName:
                await _roleAppService.UpdatePermissionsAsync(Guid.Parse(providerKey), input);

                break;

            default:
                throw new NotImplementedException();
            }
        }
Exemple #13
0
 public Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
 {
     throw new System.NotImplementedException();
 }