SuiteCRM-Core/core/legacy/Authentication.php

51 lines
978 B
PHP
Raw Normal View History

2021-03-30 19:12:01 +01:00
<?php
namespace SuiteCRM\Core\Legacy;
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
*
* @param $config
2021-03-30 19:12:01 +01:00
* @return $this
*/
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
* @throws Exception
2021-03-30 19:12:01 +01:00
*/
public function login($username, $password, $grant_type = 'password'): bool
{
if ($this->runLegacyEntryPoint()) {
$authController = new AuthenticationController();
2021-03-30 19:12:01 +01:00
$PARAMS = [];
return $authController->login($username, $password, $PARAMS);
}
throw new RuntimeException('Running legacy entry point failed');
2021-03-30 19:12:01 +01:00
}
}