public ViewResult LogIn(string returnUrl) { LogInViewModel model = new LogInViewModel { ReturnUrl = returnUrl, LoginProviders = AuthenticationManager.GetExternalAuthenticationTypes() }; return View(model); }
public async Task<ActionResult> LogIn(LogInViewModel model) { if (!ModelState.IsValid) { return View(model); } UserIntPK user = await userManager.FindAsync(model.Email, model.Password); if(user == null) { ModelState.AddModelError("", "Не правильный адрес эл. почты или пароль."); } else { ClaimsIdentity claim = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignOut(); AuthenticationManager.SignIn(claim); } return Json(new { Url = GetRedirectUrl(model.ReturnUrl) }); }