authenticate() public method

Log in to this database
Deprecation: This method is not implemented, supply authentication credentials through the connection string instead.
public authenticate ( string $username, string $password ) : array
$username string The username.
$password string The password (in plaintext).
return array Returns database response. If the login was successful, it will return 1.
Ejemplo n.º 1
0
 public function testAuthBasic()
 {
     $ok = $this->object->authenticate("testUser", "testPass");
     $this->assertEquals($ok['ok'], 1, json_encode($ok));
     $ok = $this->object->authenticate("testUser", "bar");
     $this->assertEquals($ok['ok'], 0, json_encode($ok));
 }
Ejemplo n.º 2
0
 public function __construct($host, $port, $name, $username, $password)
 {
     try {
         $client = new \MongoClient("mongodb://{$host}:{$port}");
         $this->db = new \MongoDB($client, $name);
         $this->db->authenticate($username, $password);
     } catch (\MongoException $e) {
         die('Connection failed: ' . $e->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**
  * Establishes connection to database (does not check for DB sanity)
  *
  * @return boolean
  */
 public function connect()
 {
     $this->numQueries++;
     try {
         $this->mongo = new Mongo(TeraWurflConfig::$DB_HOST, self::$CONNECTION_OPTIONS);
         $this->dbcon = $this->mongo->selectDB(TeraWurflConfig::$DB_SCHEMA);
         if (!empty(TeraWurflConfig::$DB_USER) && !empty(TeraWurflConfig::$DB_PASS)) {
             $this->dbcon->authenticate(TeraWurflConfig::$DB_USER, TeraWurflConfig::$DB_PASS);
         }
     } catch (Exception $e) {
         $this->errors[] = $e->__toString() . ', caught in ' . __CLASS__ . '::' . __METHOD__ . '()';
         $this->connected = $e->getCode();
         return false;
     }
     $this->mergecoll = $this->dbcon->selectCollection(self::$MERGE);
     $this->connected = true;
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Wrapper method for MongoDB::authenticate().
  *
  * @see http://php.net/manual/en/mongodb.authenticate.php
  * @param string $username
  * @param string $password
  * @return array
  */
 public function authenticate($username, $password)
 {
     return $this->mongoDB->authenticate($username, $password);
 }