Skip to content

Commit

Permalink
Fix authentication issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelTallet committed Jul 13, 2020
1 parent b1ba09e commit b07b773
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@
* @var string
*/
define('MPG_MONGODB_PORT', '27017');

/**
* MongoDB server database.
*
* @var string
*/
define('MPG_MONGODB_DATABASE', '');
8 changes: 6 additions & 2 deletions src/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ public function indexAction() : Response {

$databasesNames = [];

foreach ($mongoDBClient->listDatabases() as $databaseInfo) {
$databasesNames[] = $databaseInfo['name'];
if ( !empty(MPG_MONGODB_DATABASE) ) {
$databasesNames[] = MPG_MONGODB_DATABASE;
} else {
foreach ($mongoDBClient->listDatabases() as $databaseInfo) {
$databasesNames[] = $databaseInfo['name'];
}
}

return new Response(200, $this->renderView('index', [
Expand Down
4 changes: 4 additions & 0 deletions src/Helpers/MongoDBHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public static function createClient() : MongoDBClient {
$clientUri .= ':' . MPG_MONGODB_PORT;
}

if ( !empty(MPG_MONGODB_DATABASE) ) {
$clientUri .= '/' . MPG_MONGODB_DATABASE;
}

return new MongoDBClient($clientUri);

}
Expand Down

0 comments on commit b07b773

Please sign in to comment.