Controller/Component/OpauthComponent.php
public function isAuthenticated($authData) {
		// Case where user is locally logged in.
		if (!empty($this->_user)) {
			$this->updateData($this->mapData($authData));
			return $this->_user;
		}

		$Model = ClassRegistry::init($this->_authenticateObject->settings['userModel']);

		$conditions = array($Model->alias . '.' . Inflector::underscore($authData['provider']) . '_id' => $authData['uid']);
		if (isset($authData['info']['email'])) {
			$conditions = array('OR' => array_merge($conditions, array($Model->alias . '.' . 'email' => $authData['info']['email'])));
		}
		if (!empty($this->_authenticateObject->settings['scope'])) {
			$conditions += $this->_authenticateObject->settings['scope'];
		}

		$result = $Model->find('first', array(
			'conditions' => $conditions,
			'contain' => $this->_authenticateObject->settings['contain'],
			'recursive' => $this->_authenticateObject->settings['recursive']
		));

		// Case where no local user matches OAuth's provider UID and/or email.
		if (empty($result) || empty($result[$Model->alias])) {
			return false;
		}

		// Automatically log OAuth user by writing the local user's data to the session to by-pass the
		// `BaseAuthenticate::_findUser()` auto-hashing of password.
		$user = $result[$Model->alias];
		if (array_key_exists($this->_authenticateObject->settings['fields']['password'], $user)) {
			unset($user[$this->_authenticateObject->settings['fields']['password']]);
		}
		unset($result[$Model->alias]);
		$this->_user = array_merge($user, $result);
		$this->updateData($this->mapData($authData));
		return $this->_user;
	}
public function isAuthenticated($authData) {
		// Case where user is locally logged in.
		if (!empty($this->_user)) {
			$this->updateData($this->mapData($authData));
			return $this->_user;
		}

		$Model = ClassRegistry::init($this->_authenticateObject->settings['userModel']);

		$conditions = array($Model->alias . '.' . Inflector::underscore($authData['provider']) . '_id' => $authData['uid']);
		if (isset($authData['info']['email'])) {
			$conditions = array('OR' => array_merge($conditions, array($Model->alias . '.' . 'email' => $authData['info']['email'])));
		}
		if (!empty($this->_authenticateObject->settings['scope'])) {
			$conditions += $this->_authenticateObject->settings['scope'];
		}

		$result = $Model->find('first', array(
			'conditions' => $conditions,
			'contain' => $this->_authenticateObject->settings['contain'],
			'recursive' => $this->_authenticateObject->settings['recursive']
		));

		// Case where no local user matches OAuth's provider UID and/or email.
		if (empty($result) || empty($result[$Model->alias])) {
			return false;
		}

		// Automatically log OAuth user by writing the local user's data to the session to by-pass the
		// `BaseAuthenticate::_findUser()` auto-hashing of password.
		$user = $result[$Model->alias];
		if (array_key_exists($this->_authenticateObject->settings['fields']['password'], $user)) {
			unset($user[$this->_authenticateObject->settings['fields']['password']]);
		}
		unset($result[$Model->alias]);
		$this->_user = array_merge($user, $result);
		$this->updateData($this->mapData($authData));
		return $this->_user;
	}
public function isAuthenticated ( $ authData ) { // Case where user is locally logged in. if ( ! empty ( $ this -> _user ) ) { $ this -> updateData ( $ this -> mapData ( $ authData ) ) ; return $ this -> _user ; } $ Model = ClassRegistry :: init ( $ this -> _authenticateObject -> settings [ 'userModel' ] ) ; $ conditions = array ( $ Model -> alias . '.' . Inflector :: underscore ( $ authData [ 'provider' ] ) . '_id' => $ authData [ 'uid' ] ) ; if ( isset ( $ authData [ 'info' ] [ 'email' ] ) ) { $ conditions = array ( 'OR' => array_merge ( $ conditions , array ( $ Model -> alias . '.' . 'email' => $ authData [ 'info' ] [ 'email' ] ) ) ) ; } if ( ! empty ( $ this -> _authenticateObject -> settings [ 'scope' ] ) ) { $ conditions += $ this -> _authenticateObject -> settings [ 'scope' ] ; } $ result = $ Model -> find ( 'first' , array ( 'conditions' => $ conditions , 'contain' => $ this -> _authenticateObject -> settings [ 'contain' ] , 'recursive' => $ this -> _authenticateObject -> settings [ 'recursive' ] ) ) ; // Case where no local user matches OAuth's provider UID and/or email. if ( empty ( $ result ) || empty ( $ result [ $ Model -> alias ] ) ) { return false ; } // Automatically log OAuth user by writing the local user's data to the session to by-pass the // `BaseAuthenticate::_findUser()` auto-hashing of password. $ user = $ result [ $ Model -> alias ] ; if ( array_key_exists ( $ this -> _authenticateObject -> settings [ 'fields' ] [ 'password' ] , $ user ) ) { unset ( $ user [ $ this -> _authenticateObject -> settings [ 'fields' ] [ 'password' ] ] ) ; } unset ( $ result [ $ Model -> alias ] ) ; $ this -> _user = array_merge ( $ user , $ result ) ; $ this -> updateData ( $ this -> mapData ( $ authData ) ) ; return $ this -> _user ; }
Checks if OAuth2 user authenticates to local user base.

@param array $authData Opauth's data.
@return boolean The local user's data if already logged in or when the provider's UID
and/or email match a local user record. False otherwise.
Checks if OAuth2 user authenticates to local user base .