]> git.joonet.de Git - adminer.git/commitdiff
MongoDB: Modern extension doesn't allow connecting with random user/password
authorJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 15:13:28 +0000 (16:13 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 15:13:28 +0000 (16:13 +0100)
adminer/drivers/mongo.inc.php

index 02941bc4e56c4526afdc06887b0b89a57baac114..74163daa468c94aa3c1e5f7b534aaad0ee0ccf2a 100644 (file)
@@ -381,7 +381,16 @@ if (isset($_GET["mongo"])) {
 
                        function connect($uri, $options) {
                                try {
-                                       return new MongoClient($uri, $options);
+                                       $this->_link = new MongoClient($uri, $options);
+                                       if ($options["password"] != "") {
+                                               $options["password"] = "";
+                                               try {
+                                                       new MongoClient($uri, $options);
+                                                       $this->error = lang('Database does not support password.');
+                                               } catch (Exception $e) {
+                                                       // this is what we want
+                                               }
+                                       }
                                } catch (Exception $e) {
                                        $this->error = $e->getMessage();
                                }
@@ -634,14 +643,6 @@ if (isset($_GET["mongo"])) {
                if ($connection->error) {
                        return $connection->error;
                }
-               if ($password != "") {
-                       $options["password"] = "";
-                       $connection2 = new Min_DB;
-                       $connection2->connect("mongodb://$server", $options);
-                       if (!$connection2->error) {
-                               return lang('Database does not support password.');
-                       }
-               }
                return $connection;
        }