/** * @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 verify() works as expected. * * @return void */ public function testVerify() { $this->assertTrue(Password::verify('foobar', Password::hash('foobar'))); $this->assertFalse(Password::verify('foobarbaz', Password::hash('foobar'))); }