public async Task <IActionResult> Login(PieUser user) { if (ModelState.IsValid) { var temp = await _userManager.FindByNameAsync(user.Username); if (temp != null) { var result = await _signInManager.PasswordSignInAsync(temp, user.Password, false, false); if (result.Succeeded) { if (string.IsNullOrEmpty(user.ReturnUrl)) { return(RedirectToAction("Index", "Home")); } return(Redirect(user.ReturnUrl)); } } } ModelState.AddModelError("", "Username or Password not found"); return(View(user)); }
public async Task <IActionResult> Register(PieUser user) { if (ModelState.IsValid) { var temp = new IdentityUser() { UserName = user.Username }; var result = await _userManager.CreateAsync(temp, user.Password); Console.WriteLine(temp.UserName + ", " + result); if (result.Succeeded) { return(RedirectToAction("Login", "Account")); } } return(View(user)); }