當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Finder::findAccountByProviderAndClientId方法代碼示例

本文整理匯總了PHP中dektrium\user\Finder::findAccountByProviderAndClientId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Finder::findAccountByProviderAndClientId方法的具體用法?PHP Finder::findAccountByProviderAndClientId怎麽用?PHP Finder::findAccountByProviderAndClientId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dektrium\user\Finder的用法示例。


在下文中一共展示了Finder::findAccountByProviderAndClientId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: connect

 /**
  * Connects social account to user.
  * @param  ClientInterface $client
  * @return \yii\web\Response
  */
 public function connect(ClientInterface $client)
 {
     $attributes = $client->getUserAttributes();
     $provider = $client->getId();
     $clientId = $attributes['id'];
     $account = $this->finder->findAccountByProviderAndClientId($provider, $clientId);
     if ($account === null) {
         $account = \Yii::createObject(['class' => Account::className(), 'provider' => $provider, 'client_id' => $clientId, 'data' => json_encode($attributes), 'user_id' => \Yii::$app->user->id]);
         $account->save(false);
         \Yii::$app->session->setFlash('success', \Yii::t('user', 'Account has been successfully connected'));
     } else {
         \Yii::$app->session->setFlash('error', \Yii::t('user', 'This account has already been connected to another user'));
     }
     $this->action->successUrl = Url::to(['/user/settings/networks']);
 }
開發者ID:kongoon,項目名稱:yii2-user,代碼行數:20,代碼來源:SettingsController.php

示例2: authenticate

 /**
  * Logs the user in if this social account has been already used. Otherwise shows registration form.
  * @param  ClientInterface $client
  * @return \yii\web\Response
  */
 public function authenticate(ClientInterface $client)
 {
     $attributes = $client->getUserAttributes();
     $provider = $client->getId();
     $clientId = $attributes['id'];
     $account = $this->finder->findAccountByProviderAndClientId($provider, $clientId);
     if ($account === null) {
         $account = \Yii::createObject(['class' => Account::className(), 'provider' => $provider, 'client_id' => $clientId, 'data' => json_encode($attributes)]);
         $account->save(false);
     }
     if (null === ($user = $account->user)) {
         $this->action->successUrl = Url::to(['/user/registration/connect', 'account_id' => $account->id]);
     } else {
         \Yii::$app->user->login($user, $this->module->rememberFor);
     }
 }
開發者ID:uniwizardcom,項目名稱:yii2-task,代碼行數:21,代碼來源:SecurityController.php


注:本文中的dektrium\user\Finder::findAccountByProviderAndClientId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。