1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php
/**
* Created by PhpStorm.
* Copyright: Bertschi AG, 2016
* User: jbaumann
* File: TokenLogin.php
* Date: 06.01.2016
* Time: 10:43
*/
namespace JRA\Responsibilities\Responsible\Login;
use JRA\Config\Authenticate;
use JRA\Factories\InternalFactory;
use JRA\Interfaces\ConfigInterface;
use JRA\Responsibilities\Handlers\AbstractLoginHandler;
use stdClass;
class TokenLogin extends AbstractLoginHandler
{
/**
* Each chain needs to fill this function with it's own actions.
* This function contains the functionality of each chain.
*
* @param ConfigInterface $pConfig The configuration which is used to make the request.
* @param InternalFactory $pInternalFactory The factory which is responsible for the internal object creation.
* @return bool|stdClass true if the request has been processed, false otherwise
*/
protected function process(ConfigInterface $pConfig, InternalFactory $pInternalFactory)
{
if ($pConfig->getAuthenticationMethod() !== Authenticate::AUTH_METHOD_TOKEN) {
return false;
}
$token = $pConfig->getAuthenticationCredentials();
return
json_decode(
$pInternalFactory
->getGuzzleFactory()
->getGuzzleHandler()
->get(
'token/' . $token
)
->getBody()
);
}
}