Ejemplo n.º 1
0
        public IActionResult Signin(User model)
        {
            if (_PBrepository.UserAuthentication(model.Username, model.Pass) == null)
            {
                //username/password incorrect
                ViewBag.Auth_Error = true;
                return(View("Signin"));
            }

            //passed authentication
            ViewBag.Auth_Error = false;
            var u = _PBrepository.GetUserById(model.Username);

            u.SessionLive = 1;
            _PBrepository.UpdateUser(u);

            Assets.Current_user = u.Username;

            if (model.Username.ToLower() == "admin")
            {
                Assets.StoreSession = true;
                Assets.Session      = false;
            }
            else
            {
                Assets.Session      = true;
                Assets.StoreSession = false;
            }
            return(View("Index"));
        }
        public void Fail_Authentication()
        {
            // ARRANGE
            User Expected = null;

            string[] username_auth = { "admin", "Uname23", "Admin", "uname23", "ad", "Uname", "Password123", "adminpass" };
            string[] password_auth = { "adminpas", "Password", "adminpass", "Password123", "admin", "password123", "Uname23", "admin" };

            for (int i = 0; i < username_auth.Length; i++)
            {
                // ACT
                User Actual = _PBrepository.UserAuthentication(username_auth[i], password_auth[i]);

                // ASSERT
                Assert.Equal(Expected, Actual);
            }
        }