diff --git a/lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php b/lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php index fa4dcd4ee5..6cb37369bc 100644 --- a/lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php +++ b/lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php @@ -16,11 +16,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class TokenValidator { - private $app; + private $random; - public function __construct(Application $app) + public function __construct(\random $random) { - $this->app = $app; + $this->random = $random; } /** @@ -32,7 +32,7 @@ class TokenValidator public function isValid($token) { try { - $datas = $this->app['tokens']->helloToken($token); + $datas = $this->random->helloToken($token); return $datas['usr_id']; } catch (NotFoundHttpException $e) { diff --git a/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php index dbe38c860e..5b556e03d4 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/AuthenticationManagerServiceProvider.php @@ -37,7 +37,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface }); $app['authentication.token-validator'] = $app->share(function (Application $app) { - return new TokenValidator($app); + return new TokenValidator($app['tokens']); }); $app['authentication.persistent-manager'] = $app->share(function (Application $app) { diff --git a/lib/classes/Session/Logger.php b/lib/classes/Session/Logger.php index b41183dd60..151d30d557 100644 --- a/lib/classes/Session/Logger.php +++ b/lib/classes/Session/Logger.php @@ -26,7 +26,6 @@ class Session_Logger * @var databox */ protected $databox; - protected $app; const EVENT_DELETE = 'delete'; const EVENT_EDIT = 'edit'; @@ -48,9 +47,8 @@ class Session_Logger * * @return Session_Logger */ - public function __construct(Application $app, databox $databox, $log_id) + public function __construct(databox $databox, $log_id) { - $this->app = $app; $this->databox = $databox; $this->id = (int) $log_id; @@ -154,7 +152,7 @@ class Session_Logger $stmt->closeCursor(); unset($stmt, $conn); - return new Session_Logger($app, $databox, $log_id); + return new Session_Logger($databox, $log_id); } public static function load(Application $app, databox $databox) @@ -179,7 +177,7 @@ class Session_Logger if ( ! $row) throw new Exception_Session_LoggerNotFound('Logger not found'); - return new self($app, $databox, $row['id']); + return new self($databox, $row['id']); } public static function updateClientInfos(Application $app, $appId) diff --git a/tests/Alchemy/Tests/Phrasea/Authentication/Token/TokenValidatorTest.php b/tests/Alchemy/Tests/Phrasea/Authentication/Token/TokenValidatorTest.php index 68ff2e5c4f..7ad1a915c3 100644 --- a/tests/Alchemy/Tests/Phrasea/Authentication/Token/TokenValidatorTest.php +++ b/tests/Alchemy/Tests/Phrasea/Authentication/Token/TokenValidatorTest.php @@ -11,12 +11,10 @@ class TokenValidatorTest extends \PhraseanetTestCase */ public function testValidTokenIsValid() { - $app = self::$DI['app']; $usr_id = 42; - $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_VALIDATE, $usr_id); - $validator = new TokenValidator($app); + $validator = new TokenValidator(self::$DI['app']['tokens']); $this->assertEquals($usr_id, $validator->isValid($token)); } /** @@ -24,12 +22,10 @@ class TokenValidatorTest extends \PhraseanetTestCase */ public function testInvalidTokenIsNotValid() { - $app = self::$DI['app']; $usr_id = 42; - $token = self::$DI['app']['tokens']->getUrlToken(\random::TYPE_VALIDATE, $usr_id, new \DateTime('-2 hours')); - $validator = new TokenValidator($app); + $validator = new TokenValidator(self::$DI['app']['tokens']); $this->assertFalse($validator->isValid($token)); } }