View difference between Paste ID: Hj9vHLZF and vwnPAYDW
SHOW: | | - or go back to the newest paste.
1
        public function validateLogin($username, $password) {
2
                return (
3-
                        (!empty($username) || $this->invalidate('username', 'notempty')) &&
3+
                        (!empty($username) || $this->invalidate('username', 'notempty')) && // username cannot be empty. throw an error if it is.
4-
                        (!empty($password) || $this->invalidate('password', 'notempty')) &&
4+
                        (!empty($password) || $this->invalidate('password', 'notempty')) && // password cannot be empty. throw an error if it is.
5-
                        !empty($password) &&
5+
                        ($u = $this->findByUsername($username, 'password')) && // lookup the user by username
6-
                        ($u = $this->findByUsername($username, 'password')) &&
6+
                        isset($u['User']['password']) && // make sure the lookup was successful
7-
                        isset($u['User']['password']) &&
7+
                        ($hash = $this->generateHash($username, $password)) && // generate the hash for the given username/password
8-
                        ($hash = $this->generateHash($username, $password)) &&
8+
                        $u['User']['password'] == $hash // compare the hashes
9-
                        $u['User']['password'] == $hash
9+
10
        }