/** * Attempt to log a user into the application. * * @param array $arguments * @return void */ public function attempt($arguments = array()) { $username = Config::get('auth.username'); if (!Config::has('auth.username')) { throw new Exception('The username in application/config/auth.php must be defined.'); } $model = Config::get('auth.model'); // Add the username to the query $query = array('$or' => array(array(Config::get('auth.username') => $arguments[Config::get('auth.username')]))); // If we've specified an 'username_alt' field in the config, add that to the $OR if (Config::has('auth.username_alt')) { $query['$or'][] = array(Config::get('auth.username_alt') => $arguments[Config::get('auth.username')]); } $user = Epic_Mongo::db('user')->findOne($query); // This driver uses a basic username and password authentication scheme // so if the credentials match what is in the database we will just // log the user into the application and remember them if asked. $password = $arguments[Config::get('auth.password')]; // if ( ! is_null($user) and Hash::check($password, $user->password)) if (!is_null($user) and Hash::check($password, $user->password)) { return $this->login($user->_id, array_get($arguments, 'remember')); } else { if (!is_null($user) and md5($password) == $user->password) { return $this->login($user->_id, array_get($arguments, 'remember')); } } return false; }
public function testSimpleGroup() { $pipeline = array(array('$group' => array('_id' => '$v1', 'count' => array('$sum' => 1)))); $results = Epic_Mongo::db('test')->aggregate($pipeline); foreach ($results['result'] as $result) { $this->assertEquals(1000, $result['count']); } }