mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
45 lines
851 B
PHP
45 lines
851 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2013 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Authentication\Token;
|
|
|
|
use Alchemy\Phrasea\Application;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
class TokenValidator
|
|
{
|
|
private $app;
|
|
|
|
public function __construct(Application $app)
|
|
{
|
|
$this->app = $app;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the token is valid
|
|
*
|
|
* @param type $token
|
|
* @return boolean
|
|
*/
|
|
public function isValid($token)
|
|
{
|
|
try {
|
|
$datas = $this->app['tokens']->helloToken($token);
|
|
|
|
return $datas['usr_id'];
|
|
} catch (NotFoundHttpException $e) {
|
|
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|