Ejemplo n.º 1
0
 /**
  * @param \yii\authclient\ClientInterface $Client
  * @return bool
  * @throws \yii\web\ServerErrorHttpException
  */
 public function pushSocialLink(\yii\authclient\ClientInterface $Client)
 {
     /** @var \cookyii\modules\Account\resources\Account\Model $self */
     $self = $this;
     $attributes = $Client->getUserAttributes();
     /** @var $Model AccountAuthModel */
     $Model = \Yii::createObject(AccountAuthModel::class);
     $token = null;
     if ($Client instanceof \yii\authclient\BaseOAuth) {
         $Token = $Client->getAccessToken();
         $token = ArrayHelper::toArray($Token);
         $token['params'] = $Token->getParams();
     }
     return $Model::push($self->id, $Client->getId(), $attributes['id'], $token);
 }
Ejemplo n.º 2
0
 /**
  * Parse provider
  *
  * @return array
  */
 private function parseProvider()
 {
     $profile = $this->client->getUserAttributes();
     $token = $this->client->getAccessToken()->getParams();
     $data = [];
     switch ($this->type) {
         case UserProvider::TYPE_FACEBOOK:
             $data = $this->parseProviderFacebook($profile, $token);
             break;
         case UserProvider::TYPE_VKONTAKTE:
             $data = $this->parseProviderVkontakte($profile, $token);
             break;
         case UserProvider::TYPE_TWITTER:
             $data = $this->parseProviderTwitter($profile, $token);
             break;
     }
     $data['type'] = $this->type;
     return $data;
 }