public void AuthenticateCustomerTest() { //Arrange var seedDB = new List <CustomerModelDAL>(); var seed = new CustomerModelDAL { Email = "*****@*****.**", Password = PasswordHelperTool.PasswordSHA256Hasher("password"), FirstName = "First", LastName = "Last" }; seedDB.Add(seed); var controller = new CustomerUsersLogic(new CustomerDALStub(seedDB)); var rightInput1 = "*****@*****.**"; var rightInput2 = "password"; var wrongInput1 = ""; var wrongInput2 = ""; //Act var result1 = controller.AuthenticateCustomer(rightInput1, rightInput2); var result2 = controller.AuthenticateCustomer(wrongInput1, wrongInput2); //Assert Assert.IsTrue(result1 && !result2); }
public ActionResult LogIn(WrapperUserObject userInput) { if (ModelState.IsValid) { try { var result = _customerUsersLogic.AuthenticateCustomer(userInput.UserLoginObject.Email, userInput.UserLoginObject.Password); if (result) { Session["LoggedIn"] = true; Session["Username"] = userInput.UserLoginObject.Email; } else { var errorWrapper = new WrapperUserObject("Incorrect username or password", true); return(View("LogInModal", errorWrapper)); } } catch (Exception e) { var errorWrapper = new WrapperUserObject(e.ToString(), true); return(View("LogInModal", errorWrapper)); } return(RedirectToAction("Index")); } return(RedirectToAction("LogInModal")); }