Ejemplo n.º 1
0
        /// <summary>
        /// This method validates a password. Its called upon login.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public Employee ValidatePassword(string username, string password)
        {
            Employee employee = GetEmployeeByUsername(username);

            password = PasswordHashing.HashPassword(employee.Salt + password);
            if (employee.Password.Equals(password))
            {
                return(employee);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public void InsertEmployee(Employee employee)
        {
            employee.Salt     = PasswordHashing.GenerateSalt();
            employee.Password = PasswordHashing.HashPassword(employee.Salt + employee.Password);

            if (ValidateEmployeeObject(employee))
            {
                _employeeRepository.InsertEmployee(employee);
            }
            else
            {
                throw new ArgumentException("An error regarding input checks has arrised. Please check that the inputs are valid.");
            }
        }