/** * @inheritdoc */ public function readAndVerifyUserFromAuthorizationHeader($authorizationHeaderValue) { Assertion::string($authorizationHeaderValue); if (empty($authorizationHeaderValue)) { return null; } try { $credentials = $this->authorizationHeaderService->parseAuthorizationHeaderString($authorizationHeaderValue); } catch (AHSInvalidAuthorizationHeaderException $e) { throw new InvalidAuthorizationHeaderException($e->getMessage()); } try { $user = $this->userService->getUserByIdentifier($credentials->getUserIdentifier()); } catch (UserDoesNotExistException $e) { throw new InvalidUserException('User not found or password does not match'); } $verified = $this->passwordService->verify($credentials->getPassword(), $user->getPasswordHash()); if (!$verified) { throw new InvalidUserException('User not found or password does not match'); } return $user; }
/** * @param string $password * @param PasswordHashOptions $options * @dataProvider verifyAcceptsPasswordCreatedByServiceDataProvider */ public function testVerifyAcceptsPasswordCreatedByService($password, $options) { $hash = $this->passwordService->calculateHash($password, $options); $this->assertTrue($this->passwordService->verify($password, $hash)); }