コード例 #1
0
ファイル: SocialUserIdentity.php プロジェクト: ericnormannn/m
 /**
  * Authenticate
  *
  * @return bool
  */
 public function authenticate()
 {
     if ($this->account) {
         $user = $this->account->getUser();
         if ($user) {
             return $this->_processUserStatus($user);
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #2
0
 /**
  * Save Account
  *
  * @param Social_LoginAccountModel $account
  *
  * @return bool
  * @throws Exception
  */
 public function saveLoginAccount(Social_LoginAccountModel $account)
 {
     if ($account->id) {
         $accountRecord = Social_LoginAccountRecord::model()->findById($account->id);
         if (!$accountRecord) {
             throw new Exception(Craft::t('No social user exists with the ID “{id}”', ['id' => $account->id]));
         }
         $oldSocialUser = Social_LoginAccountModel::populateModel($accountRecord);
         $isNewUser = false;
     } else {
         $accountRecord = new Social_LoginAccountRecord();
         $isNewUser = true;
     }
     // populate
     $accountRecord->userId = $account->userId;
     $accountRecord->tokenId = $account->tokenId;
     $accountRecord->providerHandle = $account->providerHandle;
     $accountRecord->socialUid = $account->socialUid;
     // validate
     $accountRecord->validate();
     $account->addErrors($accountRecord->getErrors());
     if (!$account->hasErrors()) {
         $accountRecord->save(false);
         if (!$account->id) {
             $account->id = $accountRecord->id;
         }
         return true;
     } else {
         return false;
     }
 }