Exemplo 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 Check_UpdateUser()
        {
            // ARRANGE
            User U1 = new User()
            {
                Username    = "******",
                Pass        = "******",
                FullName    = "That Way",
                SessionLive = 1
            };
            User Expected = U1;

            // ACT
            _PBrepository.UpdateUser(U1);
            User Actual = _PBrepository.GetUserById("Uname23");

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