Exemplo n.º 1
0
        public void AuthenticatUserFail()
        {
            bool result;

            try
            {
                UserLogicTest.AuthenticatUser("", "123");
                result = true;
            }
            catch (AuthenticationFailedException ex)
            {
                result = false;
            }

            Assert.IsFalse(result);
        }
Exemplo n.º 2
0
 public IActionResult UserLogin(LoginViewModel user)
 {
     if (ModelState.IsValid)
     {
         try
         {
             User local = UserLogic.AuthenticatUser(user.UserName, user.Password);
             HttpContext.Session.SetInt32("id", local.Id);
             HttpContext.Session.SetString("username", local.Username);
             return(RedirectToAction("List", "List"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
             return(RedirectToAction("Index", "Home"));
         }
     }
     return(RedirectToAction("Index", "Home"));
 }