コード例 #1
0
        public async Task <IActionResult> Index(Entities.Models.Login model)
        {
            if (ModelState.IsValid)
            {
                AuthRetorno retorno = client.ValidaLoginUsuario(new LoginRequisitor(model.Usuario, model.Senha));

                if (retorno.Authenticated)
                {
                    await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
                                                  new ClaimsPrincipal(retorno.Claims),
                                                  new AuthenticationProperties
                    {
                        IsPersistent = true,
                        ExpiresUtc   = DateTime.UtcNow.AddMinutes(10)
                    });

                    return(RedirectToAction(nameof(ProjetoController.Index), "Projeto"));
                }
                else
                {
                    ModelState.AddModelError("usuario", retorno.Message);
                }
            }
            return(View(model));
        }