Esempio 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_AddUser()
        {
            // ARRANGE
            User U1 = new User
            {
                Username    = "******",
                Pass        = "******",
                FullName    = "Yah Who",
                SessionLive = 0
            };
            User Expected = U1;

            // ACT
            _PBrepository.AddUser(U1);
            User Actual = _PBrepository.GetUserById("whaa");

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