コード例 #1
0
        public ActionResult Login(LoginViewModel details, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                Usuario user = InternoUserManager.Find(details.Nome, details.Senha);

                if (user == null)
                {
                    ModelState.AddModelError("", "Nome ou senha inválido(s).");
                }

                else
                {
                    ClaimsIdentity identidade = InternoUserManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
                    InternoAuthManager.SignOut();
                    InternoAuthManager.SignIn(new AuthenticationProperties {
                        IsPersistent = false
                    }, identidade);

                    if (returnUrl == null)
                    {
                        returnUrl = "/Home";
                    }
                    return(Redirect(returnUrl));
                }
            }
            return(View(details));
        }
コード例 #2
0
 public ActionResult Logout()
 {
     InternoAuthManager.SignOut();
     return(RedirectToAction("Index", "Home", new { area = "" }));
 }