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 49 50 51 52
<?php
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 UserCredentialsLogin extends AbstractLoginHandler
{
protected function process(ConfigInterface $pConfig, InternalFactory $pInternalFactory)
{
if ($pConfig->getAuthenticationMethod() !== Authenticate::AUTH_METHOD_USER_CREDENTIALS) {
return false;
}
$userCredentials = $pConfig->getAuthenticationCredentials();
$response = json_decode(
$pInternalFactory
->getGuzzleFactory()
->getGuzzleHandler()
->get(
'user/login/' . $userCredentials['username'] . '/' . $userCredentials['password']
)
->getBody()
);
if (!empty($session = $response->session)) {
$pConfig->setSession($session);
}
return $response;
}
}