2021-03-30 19:12:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SuiteCRM\Core\Legacy;
|
|
|
|
|
2019-12-30 11:36:29 +00:00
|
|
|
use AuthenticationController;
|
|
|
|
use Exception;
|
|
|
|
use RuntimeException;
|
2021-03-30 19:12:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Authentication
|
|
|
|
* @package SuiteCRM\Core\Legacy
|
|
|
|
*/
|
|
|
|
class Authentication extends LegacyHandler
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Set the config
|
|
|
|
*
|
2019-12-30 11:36:29 +00:00
|
|
|
* @param $config
|
2021-03-30 19:12:01 +01:00
|
|
|
* @return $this
|
|
|
|
*/
|
2019-12-30 11:36:29 +00:00
|
|
|
public function setConfig($config): self
|
2021-03-30 19:12:01 +01:00
|
|
|
{
|
|
|
|
$this->config = $config;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Legacy login
|
|
|
|
*
|
|
|
|
* @param $username
|
|
|
|
* @param $password
|
|
|
|
* @param $grant_type
|
|
|
|
*
|
|
|
|
* @return boolean
|
2019-12-30 11:36:29 +00:00
|
|
|
* @throws Exception
|
2021-03-30 19:12:01 +01:00
|
|
|
*/
|
|
|
|
public function login($username, $password, $grant_type = 'password'): bool
|
|
|
|
{
|
|
|
|
if ($this->runLegacyEntryPoint()) {
|
2019-12-30 11:36:29 +00:00
|
|
|
$authController = new AuthenticationController();
|
2021-03-30 19:12:01 +01:00
|
|
|
|
|
|
|
$PARAMS = [];
|
|
|
|
|
|
|
|
return $authController->login($username, $password, $PARAMS);
|
|
|
|
}
|
|
|
|
|
2019-12-30 11:36:29 +00:00
|
|
|
throw new RuntimeException('Running legacy entry point failed');
|
2021-03-30 19:12:01 +01:00
|
|
|
}
|
|
|
|
}
|