public async Task <bool> Handle(string clientId, CancellationToken cancellationToken) { var client = await _oauthClientRepository.FindOAuthClientById(clientId, cancellationToken); if (client == null) { _logger.LogError($"Client cannot be deleted because the client '{clientId}' doesn't exist"); throw new OAuthClientNotFoundException(ErrorCodes.INVALID_REQUEST, string.Format(ErrorMessages.UNKNOWN_CLIENT, clientId)); } await _oauthClientRepository.Delete(client, cancellationToken); await _oauthClientRepository.SaveChanges(cancellationToken); _logger.LogInformation($"The client '{clientId}' has been removed"); return(true); }
public async Task <bool> Handle(string clientId, JObject content, CancellationToken cancellationToken) { var extractedClient = ExtractClient(content); var oauthClient = await _oauthClientRepository.FindOAuthClientById(clientId, cancellationToken); if (oauthClient == null) { _logger.LogError($"The client '{clientId}' doesn't exist"); throw new OAuthClientNotFoundException(ErrorCodes.INVALID_REQUEST, string.Format(ErrorMessages.UNKNOWN_CLIENT, clientId)); } await UpdateClient(oauthClient, extractedClient, cancellationToken); await _oauthClientRepository.Update(oauthClient, cancellationToken); await _oauthClientRepository.SaveChanges(cancellationToken); return(true); }
public async Task <string> Handle(string language, JObject jObj, CancellationToken cancellationToken) { var currentDateTime = DateTime.UtcNow; DateTime?expirationDateTime = null; if (_options.ClientSecretExpirationInSeconds != null) { expirationDateTime = currentDateTime.AddSeconds(_options.ClientSecretExpirationInSeconds.Value); } var parameter = jObj.ToCreateOpenIdClientParameter(); var openidClient = OpenIdClient.Create(parameter.ApplicationKind.Value, parameter.ClientName, language, expirationDateTime, _options.DefaultTokenExpirationTimeInSeconds, _options.DefaultRefreshTokenExpirationTimeInSeconds); await _oauthClientRepository.Add(openidClient, cancellationToken); await _oauthClientRepository.SaveChanges(cancellationToken); return(openidClient.ClientId); }