Exemple #1
0
        public async Task <bool> Handle(RemoveClientSecretCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var client = await _clientRepository.FindByClientIdAsync(request.ClientId);

            if (client == null)
            {
                await _bus.RaiseEvent(new DomainNotification("key_not_found", $"Client named {request.ClientId} not found"));

                return(false);
            }

            var secret = await _clientSecretRepository.FindByIdAsync(request.Id);

            if (secret != null)
            {
                await _clientSecretRepository.RemoveAsync(secret);

                if (Commit())
                {
                    await _bus.RaiseEvent(new ClientSecretRemovedEvent(request.ClientId, request.Id));

                    return(true);
                }
            }

            return(true);
        }
Exemple #2
0
        public async Task <bool> Handle(RemoveClientSecretCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var savedClient = await _clientRepository.GetClient(request.ClientId);

            if (savedClient == null)
            {
                await Bus.RaiseEvent(new DomainNotification("Client", "Client not found"));

                return(false);
            }

            if (savedClient.ClientSecrets.All(f => f.Id != request.Id))
            {
                await Bus.RaiseEvent(new DomainNotification("Client Secret", "Invalid secret"));

                return(false);
            }

            _clientSecretRepository.Remove(request.Id);

            if (await Commit())
            {
                await Bus.RaiseEvent(new ClientSecretRemovedEvent(request.Id, request.ClientId));

                return(true);
            }
            return(false);
        }
Exemple #3
0
 public async Task RemoveSecretAsync(string clientId, int id)
 {
     var command = new RemoveClientSecretCommand(clientId, id);
     await _bus.SendCommand(command);
 }