Ejemplo n.º 1
0
 /**
  * @param \yii\authclient\ClientInterface $client
  */
 public function successCallback($client)
 {
     $attributes = $client->getUserAttributes();
     /** @var \app\services\authclient\authClientInterface $client */
     $client->saveToken();
     if (Yii::$app->user->isGuest) {
         $user = $client->login($attributes);
         if (is_null($user)) {
             $user = $client->register($attributes);
         }
         if (!is_null($user)) {
             Yii::$app->user->login($user);
         }
     } else {
         $client->attach($attributes, Yii::$app->user->identity);
     }
     $client->setAuthFlag();
     Yii::$app->user->setReturnUrl($_SERVER['HTTP_REFERER']);
 }