Esempio n. 1
0
 private async Task <bool> HasPermissionAsync(long userId, PermissionGrantInfo permissionGrant)
 {
     return(await _userPermissionSettingRepository.FirstOrDefaultAsync(
                p => p.UserId == userId &&
                p.Name == permissionGrant.Name &&
                p.IsGranted == permissionGrant.IsGranted
                ) != null);
 }
Esempio n. 2
0
 private async Task RemovePermissionAsync(User user, PermissionGrantInfo permissionGrant)
 {
     await _userPermissionSettingRepository.DeleteAsync(
         permissionSetting => permissionSetting.UserId == user.Id &&
         permissionSetting.Name == permissionGrant.Name &&
         permissionSetting.IsGranted == permissionGrant.IsGranted
         );
 }
Esempio n. 3
0
 private async Task RemovePermissionAsync(Role role, PermissionGrantInfo permissionGrant)
 {
     await _rolePermissionSettingRepository.DeleteAsync(
         permissionSetting => permissionSetting.RoleId == role.Id &&
         permissionSetting.Name == permissionGrant.Name &&
         permissionSetting.IsGranted == permissionGrant.IsGranted
         );
 }
Esempio n. 4
0
 private async Task <bool> HasPermissionAsync(int roleId, PermissionGrantInfo permissionGrant)
 {
     return(await _rolePermissionSettingRepository.FirstOrDefaultAsync(
                p => p.RoleId == roleId &&
                p.Name == permissionGrant.Name &&
                p.IsGranted == permissionGrant.IsGranted
                ) != null);
 }
Esempio n. 5
0
        private async Task AddPermissionAsync(User user, PermissionGrantInfo permissionGrant)
        {
            if (await HasPermissionAsync(user.Id, permissionGrant))
            {
                return;
            }

            await _userPermissionSettingRepository.InsertAsync(
                new UserPermissionSetting
            {
                TenantId  = user.TenantId,
                UserId    = user.Id,
                Name      = permissionGrant.Name,
                IsGranted = permissionGrant.IsGranted
            });
        }
Esempio n. 6
0
        private async Task AddPermissionAsync(Role role, PermissionGrantInfo permissionGrant)
        {
            if (await HasPermissionAsync(role.Id, permissionGrant))
            {
                return;
            }

            await _rolePermissionSettingRepository.InsertAsync(
                new RolePermissionSetting
            {
                TenantId  = role.TenantId,
                RoleId    = role.Id,
                Name      = permissionGrant.Name,
                IsGranted = permissionGrant.IsGranted
            });
        }