public static function connectWithUser(BaseClientInterface $client)
    {
        if (Yii::$app->user->isGuest) {
            Yii::$app->session->setFlash('danger', Yii::t('user', 'Something went wrong'));
            return;
        }

        $account = static::fetchAccount($client);

        if ($account->user === null) {
            $account->link('user', Yii::$app->user->identity);
            Yii::$app->session->setFlash('success', Yii::t('user', 'Your account has been connected'));
        } else {
            Yii::$app->session->setFlash('danger', Yii::t('user', 'This account has already been connected to another user'));
        }
    }
public static function connectWithUser(BaseClientInterface $client)
    {
        if (Yii::$app->user->isGuest) {
            Yii::$app->session->setFlash('danger', Yii::t('user', 'Something went wrong'));
            return;
        }

        $account = static::fetchAccount($client);

        if ($account->user === null) {
            $account->link('user', Yii::$app->user->identity);
            Yii::$app->session->setFlash('success', Yii::t('user', 'Your account has been connected'));
        } else {
            Yii::$app->session->setFlash('danger', Yii::t('user', 'This account has already been connected to another user'));
        }
    }
public static function connectWithUser ( BaseClientInterface $ client ) { if ( Yii :: $ app -> user -> isGuest ) { Yii :: $ app -> session -> setFlash ( 'danger' , Yii :: t ( 'user' , 'Something went wrong' ) ) ; return ; } $ account = static :: fetchAccount ( $ client ) ; if ( $ account -> user === null ) { $ account -> link ( 'user' , Yii :: $ app -> user -> identity ) ; Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( 'user' , 'Your account has been connected' ) ) ; } else { Yii :: $ app -> session -> setFlash ( 'danger' , Yii :: t ( 'user' , 'This account has already been connected to another user' ) ) ; } }
Tries to find an account and then connect that account with current user.

@param BaseClientInterface $client
Tries to find an account and then connect that account with current user .