Ejemplo n.º 1
0
        public bool ValidateUser(string username, string password)
        {
            bool valid = false;

            department user = null;

            using (TimetablingSystemContext _db = new TimetablingSystemContext())
            {
                user = _db.departments.FirstOrDefault(d => d.code == username);

            }

            string hashedUserInput = HashPassword(password, user.salt);

            if (user != null) if (user.hashedPassword == hashedUserInput) valid = true;

            return valid;
        }
Ejemplo n.º 2
0
        public ActionResult SetupUsers()
        {
            using (var _db = new TimetablingSystemContext())
            {

                var deptList = _db.departments;

                foreach (DBInterface.department dept in deptList)
                {

                    dept.salt = auth.GenerateSalt();
                    dept.hashedPassword = auth.HashPassword("w6vnh4n", dept.salt);

                }

                _db.SaveChanges();

            }

            return Content("All users returned to default password");
        }