Пример #1
0
 /**
  * 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;
     }
 }
Пример #2
0
 /**
  * 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;
     }
 }
Пример #3
0
 public function run()
 {
     // this method is called by CController::endWidget()
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerCoreScript('jquery.ui');
     $cs->registerCssFile($cs->getCoreScriptUrl() . '/jui/css/base/jquery-ui.css');
     $cs->registerScriptFile($this->_assetsUrl . '/script.js');
     $cs->registerCssFile($this->_assetsUrl . '/styles.css');
     if (isset($this->invitefrnd)) {
         if ($this->invitefrnd == "facebook") {
             $providers = "facebook";
             $this->Isfb = "facebook";
             //print_r($providers);
             //exit;
         } elseif ($this->invitefrnd == "all") {
             //echo "hiii";
             //$providers = $this->config['providers'];
             $providers = "google";
             $this->Isfb = "all";
             $invitefriends = array();
             if (isset(Yii::app()->session['invitefriends'])) {
                 unset(Yii::app()->session['invitefriends']);
             }
             $invitefriends["inviteallfriends"] = "network-page";
             Yii::app()->session['invitefriends'] = $invitefriends;
             /*foreach ($providers as &$provider) {
             				$provider['active']=false;
             			}
             				if (isset(Yii::app()->session['login'])) {
             			//echo "hiii--".Yii::app()->session['login']['id']."--no id";
             			foreach (HaLogin::getLogins(Yii::app()->session['login']['id']) as $login) {
             				$providers[$login->loginProvider]['active']=true;
             			}
             		}*/
         }
     } else {
         /*if(isset(Yii::app()->session['userinfo']))
         		unset(Yii::app()->session['userinfo']);*/
         $providers = $this->config['providers'];
         $this->Isfb = "no";
         foreach ($providers as &$provider) {
             $provider['active'] = false;
         }
         if (isset(Yii::app()->session['login'])) {
             //echo "hiii--".Yii::app()->session['login']['id']."--no id";
             foreach (HaLogin::getLogins(Yii::app()->session['login']['id']) as $login) {
                 $providers[$login->loginProvider]['active'] = true;
             }
         }
     }
     $this->render('providers', array('baseUrl' => $this->config['baseUrl'], 'providers' => $providers, 'assetsUrl' => $this->_assetsUrl, 'isFb' => $this->Isfb));
 }
 public function run()
 {
     // this method is called by CController::endWidget()
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('jquery');
     $cs->registerCoreScript('jquery.ui');
     $cs->registerCssFile($cs->getCoreScriptUrl() . '/jui/css/base/jquery-ui.css');
     $cs->registerScriptFile($this->_assetsUrl . '/script.js');
     $cs->registerCssFile($this->_assetsUrl . '/styles.css');
     $providers = $this->config['providers'];
     foreach ($providers as &$provider) {
         $provider['active'] = false;
     }
     if (!Yii::app()->user->isGuest) {
         foreach (HaLogin::getLogins(Yii::app()->user->id) as $login) {
             $providers[$login->loginProvider]['active'] = true;
         }
     }
     $this->render('providers', array('baseUrl' => $this->config['baseUrl'], 'providers' => $providers, 'assetsUrl' => $this->_assetsUrl));
 }
Пример #5
0
 public function actionUnlink()
 {
     $login = HaLogin::getLogin(Yii::app()->user->getid(), $_POST['hybridauth-unlinkprovider']);
     $login->delete();
     $this->redirect(Yii::app()->getRequest()->urlReferrer);
 }
Пример #6
0
 public function actionInvitefbfriends()
 {
     $this->layout = '/layouts/column1';
     $this->header = 'network';
     $this->allowjs = "allowminjs";
     if (isset(Yii::app()->session['login'])) {
         $id = Yii::app()->session['login']['id'];
         Yii::import('application.modules.hybridauth.models.*');
         $checkfbid = HaLogin::model()->findByAttributes(array('userId' => $id, 'loginProvider' => 'facebook'));
         /*print_r($checkfbid->loginProviderIdentifier);
           
           
           
           exit;*/
         if ($checkfbid) {
             $fbid = $checkfbid->loginProviderIdentifier;
             $this->render('invitefbfriends', array('userid' => $id, 'fbid' => $fbid));
         } else {
             $fbid = 1;
             $this->render('invitefbfriends', array('userid' => $id, 'fbid' => $fbid));
         }
     } else {
         $this->redirect(array('/'));
     }
 }