/** * @see \Ableron\Modules\Core\Services\Authentication\AuthenticationInterface::authenticateManually() */ public static function authenticateManually($username, $password) { // get user in case username exists $user = Application::getPersistenceManager()->getRepository('UserEntity')->findByUsername($username); // check password if ($user !== null && Password::verify($password, $user->getPasswordHash())) { // rehash password if necessary if (Password::needsRehash($user->getPasswordHash())) { $user->setPasswordHash(Password::hash($password)); } // return the user object return $user; } // credentials invalid return null; }
/** * Tests whether hash() and needsRehash() are using the same default algorithm. * * @return void */ public function testHashAndReHashAreUsingSameDefaultAlgorithm() { $this->assertFalse(Password::needsRehash(Password::hash('foobar'))); }