Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,AppKey,AppValue,IsActive")] ClientSecrets clientSecrets)
        {
            if (ModelState.IsValid)
            {
                clientSecrets.AppKey      = _jwtManager.EncryptText(clientSecrets.Name + clientSecrets.AppKey, clientSecrets.AppKey);
                clientSecrets.AppValue    = _jwtManager.GenerateAppToken(clientSecrets.Name, clientSecrets.AppKey);
                clientSecrets.CreatedDate = DateTime.UtcNow;
                clientSecrets.UpdateDate  = DateTime.UtcNow;
                _context.Add(clientSecrets);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientSecrets));
        }