public function addProvider(Provider $provider) { $this->providers[$provider->getId()] = $provider; $provider->setCallback($this); $provider->checkState(); }
/** * @return int */ public function getProviderId() { return parent::getId(); }
/** * Authenticates the session owner with the provider * * @param \Elgg\HybridAuth\Provider $provider Provider * @param bool $addauth Add auth records * @return \Hybrid_User_Profile|false */ public function authenticate(Provider $provider, $addauth = true) { try { $this->restore(); $adapter = $this->getClient()->authenticate($provider->getId(), $provider->getAdapterParams()); $profile = $adapter ? $adapter->getUserProfile() : false; $this->save(); if ($profile && $addauth) { $this->addAuthRecord($provider, $profile); } } catch (\Exception $e) { elgg_log($e->getMessage(), 'ERROR'); set_input('error', $e->getMessage()); $this->deauthenticate($provider); } return $profile; }
/** * Get the provider ID * @param string $provider * @return int */ private function getProviderId($provider) { if ($provider === null || trim($provider) == '') { return null; } if (!isset($this->providerIds[$provider])) { $this->providerIds[$provider] = Provider::getId($provider); } return $this->providerIds[$provider]; }