Esempio n. 1
0
        public Task <PermisionCheckResult> CheckAsync <T>(T request) where T : IUserCommand
        {
            if (_serviceProvider.GetService(typeof(IPermissionCheck <T>)) is IPermissionCheck <T> check)
            {
                return(check.CheckAsync(request));
            }

            return(Task.FromResult(PermisionCheckResult.Ok()));
        }
Esempio n. 2
0
        private void Handle(PermisionCheckResult result)
        {
            if (result.Success)
            {
                _logger.LogDebug("Permission check succeeded for command {Command}", CommandTypeName);

                return;
            }

            _logger.LogDebug("Permission check failed for command {Command} with message {Message}",
                             CommandTypeName, result.Message);

            throw new PermissionException(result.Message);
        }