public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await Task.Run(() => _usersRepository.GetUserByAppLogin(model.Login, model.Password)); if (user != null) { OwinAuthHelper.SignIn(Request.GetOwinContext(), user); return Redirect(returnUrl ?? Url.Action("Index", "Game")); } ModelState.AddModelError("", "Incorrect Username or password"); return View(); } return View(); }
public async Task<ActionResult> SignUp(LoginViewModel model, string returnUrl) { var newUser = await _usersRepository.CreateUser(model.Login, model.Password); if (newUser != null) { OwinAuthHelper.SignIn(Request.GetOwinContext(), newUser); return Redirect(returnUrl ?? Url.Action("Index", "Game")); } return View(); }