Commit 043e210e authored by jeremyjaouen's avatar jeremyjaouen Committed by Thomas Untoja
Browse files

fix(login): Use correct database name for api login (#9880)

parent 997f86a5
......@@ -58,7 +58,7 @@ class AuthenticationRepositoryRDB implements AuthenticationRepositoryInterface
{
global $dependencyInjector;
$pearDB = new \CentreonDB(
$this->db->getCentreonDbName(),
\CentreonDB::LABEL_DB_CONFIGURATION,
3,
true
);
......
......@@ -48,6 +48,8 @@ require_once __DIR__ . '/centreonLog.class.php';
*/
class CentreonDB extends \PDO
{
public const LABEL_DB_CONFIGURATION = 'centreon';
public const LABEL_DB_REALTIME = 'centstorage';
private static $instance = [];
protected $db_type = "mysql";
protected $db_port = "3306";
......@@ -77,14 +79,14 @@ class CentreonDB extends \PDO
/**
* Constructor
*
* @param string $db | centreon, centstorage, or ndo
* @param string $db | centreon, centstorage
* @param int $retry
* @param bool $silent | when silent is set to false, it will display an HTML error msg,
* otherwise it will throw an Exception
*
* @throws Exception
*/
public function __construct($db = "centreon", $retry = 3, $silent = false)
public function __construct($db = self::LABEL_DB_CONFIGURATION, $retry = 3, $silent = false)
{
try {
$conf_centreon['hostCentreon'] = hostCentreon;
......@@ -133,12 +135,11 @@ class CentreonDB extends \PDO
];
switch (strtolower($db)) {
case "centstorage":
case self::LABEL_DB_REALTIME:
$this->dsn['hostspec'] = $conf_centreon["hostCentstorage"];
$this->dsn['database'] = $conf_centreon["dbcstg"];
break;
case "centreon":
case "default":
default:
$this->dsn['hostspec'] = $conf_centreon["hostCentreon"];
$this->dsn['database'] = $conf_centreon["db"];
break;
......@@ -317,9 +318,9 @@ class CentreonDB extends \PDO
* @return CentreonDB
* @throws Exception
*/
public static function factory($name = "centreon")
public static function factory($name = self::LABEL_DB_CONFIGURATION)
{
if (!in_array($name, ['centreon', 'centstorage', 'ndo'])) {
if (!in_array($name, [self::LABEL_DB_CONFIGURATION, self::LABEL_DB_REALTIME])) {
throw new Exception("The datasource isn't defined in configuration file.");
}
if (!isset(self::$instance[$name])) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment