コード例 #1
0
        public void LoginPerson_LoginPasswordFalse_UserNull()
        {
            //Arrange
            LoginVM modelTest = new LoginVM()
            {
                Login    = "******",
                Password = "******"
            };

            //Act
            Person user = authenticationBusinessToTest.LoginPerson(modelTest);

            //Assert
            Assert.IsNull(user);
        }
コード例 #2
0
        public ActionResult Login(LoginVM model)
        {
            AuthenticationBusiness userBL = new AuthenticationBusiness();
            Person user = userBL.LoginPerson(model);

            if (user != null)
            {
                ConnexionService.SetSession(user);
                TempData["LoginMessage"] = "Welcome " + model.Login;
                if (user is Student)
                {
                    return(RedirectToAction(nameof(HomeController.Index), "Home"));
                }
                else if (user is Instructor)
                {
                    return(RedirectToAction(nameof(HomeController.Index), "Home"));
                }
            }

            else
            {
                ModelState.AddModelError("", "Invalid login or password");
                return(View());
            }

            return(View());
        }