public function testGetByGoogleId()
 {
     $u = new User($this->container);
     $this->assertNotFalse($u->create(array('username' => 'user1', 'password' => '123456', 'google_id' => '1234')));
     $this->assertNotFalse($u->create(array('username' => 'user2', 'password' => '123456', 'google_id' => '')));
     $this->assertNotEmpty($u->getByGoogleId('1234'));
     $this->assertEmpty($u->getByGoogleId(''));
 }
Exemple #2
0
 /**
  * Authenticate a Google user
  *
  * @access public
  * @param  string  $google_id   Google unique id
  * @return boolean
  */
 public function authenticate($google_id)
 {
     $userModel = new User($this->db, $this->event);
     $user = $userModel->getByGoogleId($google_id);
     if ($user) {
         // Create the user session
         $userModel->updateSession($user);
         // Update login history
         $lastLogin = new LastLogin($this->db, $this->event);
         $lastLogin->create(LastLogin::AUTH_GOOGLE, $user['id'], $userModel->getIpAddress(), $userModel->getUserAgent());
         return true;
     }
     return false;
 }