0_libs/imperium/InterfaceToken/userToken.php line 29

Open in your IDE?
  1. <?php
  2. namespace Imperium\InterfaceToken;
  3. use Imperium\Config\iConfig;
  4. use Imperium\InterfaceBase\AuthTokenBase;
  5. use Imperium\InterfaceBase\WebHookBase;
  6. use Imperium\StaticUtils\Crypt;
  7. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  8. class userToken extends AuthTokenBase
  9. {
  10.     protected $api_verify_endpoint '/authentication/tokens/users/verify';
  11.     protected $api_signin_endpoint '/authentication/tokens/users/signin';    
  12.     protected $api_uri_key 'api_idbl';
  13.     private $session;
  14.     function __construct$token=null,SessionInterface $session=null
  15.     { 
  16.         if($token && !empty($token)){
  17.             $this->user_token $token;
  18.             $resp $this->verify($this->user_token);
  19.             if($resp->status==200)
  20.                 $this->payload $resp->payload;
  21.         }
  22.         if($session != null){
  23.             $this->session $session;
  24.             $token $this->session->get('user_token');
  25.             if ($token){
  26.                 $this->user_token $token;
  27.                 $resp $this->verify($this->user_token);
  28.                 if($resp->status==200 && isset($resp->payload))
  29.                     $this->payload $resp->payload;
  30.             }
  31.         }
  32.     } 
  33.     function authenticate($username$password)
  34.     {
  35.         $resp $this->auth($username,$password);
  36.         if($resp->status == 200 && $this->session != null){
  37.             $this->session->set('user_token',$resp->token);
  38.         }
  39.         return $resp;
  40.     }
  41. }