/** * Authenticates a user. * @return boolean whether authentication succeeds. */ public function authenticate() { if (strtolower($this->loginProvider) == 'openid') { if (!isset($_GET['openid-identity'])) { throw new Exception('You chose OpenID but didn\'t provide an OpenID identifier'); } else { $params = array("openid_identifier" => $_GET['openid-identity']); } } else { $params = array(); } $adapter = $this->_hybridAuth->authenticate($this->loginProvider, $params); if ($adapter->isUserConnected()) { $this->_adapter = $adapter; $this->loginProviderIdentifier = $this->_adapter->getUserProfile()->identifier; $user = HaLogin::getUser($this->loginProvider, $this->loginProviderIdentifier); if ($user == null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { $this->id = $user->User_ID; $this->username = $user->Email; $this->errorCode = self::ERROR_NONE; } return $this->errorCode == self::ERROR_NONE; } }
/** * Authenticates a user. * @return boolean whether authentication succeeds. */ public function authenticate() { if (strtolower($this->loginProvider) == 'openid') { if (!isset($_GET['openid-identity'])) { throw new Exception('You chose OpenID but didn\'t provide an OpenID identifier'); } else { $params = array("openid_identifier" => $_GET['openid-identity']); } } else { $params = array(); } $adapter = $this->_hybridAuth->authenticate($this->loginProvider, $params); if ($adapter->isUserConnected()) { $this->_adapter = $adapter; $this->loginProviderIdentifier = $this->_adapter->getUserProfile()->identifier; $user_profile = $this->_adapter->getUserProfile(); $this->userContacts = $this->_adapter->getUserContacts(); /*$user_contacts = $this->_adapter->getUserContacts(); print_r($user_contacts); exit;*/ $userinfo = array(); if (isset(Yii::app()->session['userinfo'])) { unset(Yii::app()->session['userinfo']); } $userinfo["fname"] = $user_profile->firstName; $userinfo["lname"] = $user_profile->lastName; $userinfo["email"] = $user_profile->email; $userinfo["zip"] = $user_profile->zip; $userinfo["gender"] = $user_profile->gender; $userinfo["photourl"] = $user_profile->photoURL; $userinfo["country"] = $user_profile->country; $userinfo["region"] = $user_profile->region; $userinfo["city"] = $user_profile->city; $userinfo["age"] = $user_profile->age; $userinfo["birthday"] = $user_profile->birthDay; $userinfo["birthmonth"] = $user_profile->birthMonth; $userinfo["birthyear"] = $user_profile->birthYear; $userinfo["SocialNetworkID"] = $user_profile->identifier; $userinfo["SocialNetwork"] = $this->loginProvider; if ($user_profile->birthDay != "") { $userinfo["dob"] = $user_profile->birthDay . "-" . $user_profile->birthMonth . "-" . $user_profile->birthYear; } Yii::app()->session['userinfo'] = $userinfo; $user = HaLogin::getUser($this->loginProvider, $this->loginProviderIdentifier); //print_r($user); //exit; if ($user == null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { $this->userid = $user->userid; $this->useremail = $user->email; $this->username = $user->fname . " " . $user->lname; $this->userData = $user->usertypeid; $this->Issuperuser = $user->superuser; $this->password = "******"; $this->errorCode = self::ERROR_NONE; } return $this->errorCode == self::ERROR_NONE; } }