public void CanLoginSuccessfullyWithCorrcectUserNameAndPassword() { var request = new LoginRequest {Username = Username, Password = Password}; SetupMockUserRepo(); var handler = new LoginRequestHandle(_mockUserRepo.Object); var response = handler.Handle(request); Assert.That(response.Status, Is.EqualTo(ResponseCodes.Success)); }
public void ReturnsFailureCodeIfAUserCouldNotBeFoundWithCredentials() { var request = new LoginRequest { Username = "******", Password = Password }; SetupMockUserRepo(); var handler = new LoginRequestHandle(_mockUserRepo.Object); var response = handler.Handle(request); Assert.That(response.Status, Is.EqualTo(ResponseCodes.LoginAndPasswordMismatch)); }
public ActionResult LogIn(LogOnModel model) { var handler = new LoginRequestHandle(new UserRepository()); var request = new LoginRequest { Password = model.Password, Username = model.UserName }; var response = handler.Handle(request); if (response.Status == ResponseCodes.Success) { FormsAuthentication.SetAuthCookie(model.UserName, false); return RedirectToAction("ChooseProfile", "Profile"); } var errorMessage = response.Status.GetMessage(); ModelState.AddModelError("", errorMessage); return View(model); }