public function test_Hash_ReturnsUniqueValues() { $password = new Password(); $correct = 'test1234'; $hash = $password->get_hash($correct); $check = $password->check($correct, $hash); $this->assertTrue($check, 'Hashing a password and then checking it does not return true!'); $wrong = 'wrong!'; $check = $password->check($wrong, $hash); $this->assertFalse($check, 'Hashing a password and then checking it with an incorrect password does not return false!'); }
/** * Logs a user in. * * @param obj $user The user object to check against. * @param string $password The password to check against. * @param string $ip The user's IP address. * @access public * @return bool */ public function login($user, $password, $ip) { if (!$user) { return false; } if (!Password::check($password, $user->password)) { return false; } $user->ip = sprintf('%u', ip2long($ip)); $user->last_login = date('Y-m-d H:i:s'); $user->store(); $this->_create($user->get_pk()); return true; }