Ejemplo n.º 1
0
 public ActionResult Login(LoginViewModel model)
 {
     Request.GetOwinContext().Authentication.SignOut("ApplicationCookie");
     SideBarDataStore.Dispose();
     if (ModelState.IsValid)
     {
         var user = UserDataStore.User.Where(x => x.Email == model.Email && x.Password == model.Password).SingleOrDefault();
         if (user != null)
         {
             var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, user.FirstName), new Claim(ClaimTypes.Email, user.Email), new Claim(ClaimTypes.Sid, user.Id.ToString()) }, "ApplicationCookie");
             Request.GetOwinContext().Authentication.SignIn(identity);
             return(Redirect(GetRedirectUrl(model.ReturnUrl)));
         }
         else
         {
             ModelState.AddModelError("", "invalid username or password");
         }
     }
     return(View());
 }
Ejemplo n.º 2
0
 public ActionResult Logout()
 {
     Request.GetOwinContext().Authentication.SignOut("ApplicationCookie");
     SideBarDataStore.Dispose();
     return(RedirectToAction("Login"));
 }