public async Task <IActionResult> RegenerateKey()
        {
            var allApiKeys = await _apiKeyService.GetValidKeys();

            _log.Info($"{allApiKeys.Count} API keys found. Regenerating them all...");

            foreach (var existingApiKey in allApiKeys)
            {
                await _apiKeyService.GenerateApiKeyAsync(existingApiKey.ClientId, existingApiKey.WalletId);
            }

            return(Ok($"{allApiKeys.Count} API keys were scheduled for regeneration."));
        }
        public async Task <IActionResult> RegenerateKey([FromBody] RegenerateKeyRequest request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            var client = await _clientAccountService.GetClientByIdAsync(request.ClientId);

            if (client == null)
            {
                ModelState.AddModelError("ClientId", request.ClientId);
                return(BadRequest(ModelState));
            }

            var wallet = await _clientAccountService.GetWalletAsync(request.WalletId);

            if (wallet == null)
            {
                ModelState.AddModelError("WalletId", request.WalletId);
                return(BadRequest(ModelState));
            }

            var apiKey = await _apiKeyService.GenerateApiKeyAsync(request.ClientId, request.WalletId);

            return(Ok(_mapper.Map <ApiKeyDto>(apiKey)));
        }
Example #3
0
        public async Task <ApiKey> CreateWallet(string clientId, bool apiv2Only = false, string name = null, string description = null)
        {
            var wallet = await _clientAccountService.CreateWalletAsync(new CreateWalletRequest(
                                                                           clientId : clientId,
                                                                           type : WalletType.Trusted,
                                                                           name : name,
                                                                           description : description));

            var apiKey = await _apiKeyService.GenerateApiKeyAsync(clientId, wallet.Id, apiv2Only, name);

            return(apiKey);
        }