Files
Phraseanet/lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php
2013-06-17 17:01:35 +02:00

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;
}
}