Files
Phraseanet/lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php
2014-01-06 15:28:12 +01:00

45 lines
851 B
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 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;
}
}