Beispiel #1
0
        public async Task Test_CreateApiKeyCommand_Serialization()
        {
            var user = TestHelper.SetPrincipal(USERNAMES.Unit);
            var cmd  = new CreateApiKeyCommand("name", "description", "http://somedomain.com", "http://somedomain.com/app").SetUserContext(user);

            EnsureCommandIsSerialziable(cmd);
        }
        public async Task <ActionResult> Create(ApiKeyCreateRequest model)
        {
            if (!VoatSettings.Instance.ApiKeyCreationEnabled)
            {
                return(RedirectToAction("Index"));
            }
            else if (ModelState.IsValid)
            {
                var cmd = new CreateApiKeyCommand(model.Name, model.Description, model.AboutUrl, model.RedirectUrl).SetUserContext(User);
                await cmd.Execute();

                return(RedirectToAction("Index"));
            }
            return(View("Edit"));
        }
Beispiel #3
0
 public Task <Response <ApiKey> > CreateApiKey(CreateApiKeyCommand command)
 {
     return(_context.CreateApiKey(command));
 }
Beispiel #4
0
 public ActionResult <string> GenerateApiKey([FromBody] CreateApiKeyCommand command)
 {
     _logger.LogWarning("Post Generate Api Key");
     return(Created(Guid.NewGuid().ToString(), "save successfully"));
 }