/** * Renders the main content, which includes all external services links. */ protected function renderMainContent() { echo Html::beginTag('ul', ['class' => 'auth-clients clear']); $clients = $this->getClients(); $authorizedClients = array_keys(Auth::getAuthorizedClients()); foreach ($clients as $externalService) { if ($this->displayClients == self::DISPLAY_ALL || $this->displayClients == self::DISPLAY_AUTHORIZED && in_array($externalService->getName(), $authorizedClients) || $this->displayClients == self::DISPLAY_NON_AUTHORIZED && !in_array($externalService->getName(), $authorizedClients)) { $shortViewClass = $this->shortView ? 'short-view' : ''; echo Html::beginTag('li', ['class' => 'auth-client ' . $shortViewClass . ' ' . $externalService->getName()]); $this->clientLink($externalService); echo Html::endTag('li'); } } echo Html::endTag('ul'); }
/** * @return \yii\db\ActiveQuery */ public static function unlinkClient($client) { $userId = Yii::$app->user->id; $client = Auth::find()->where(['user_id' => $userId, 'source' => $client])->one(); return $client ? $client->delete() : false; }
public function actionUnlinkOauth($redirectUrl = null) { if (Yii::$app->user->isGuest) { throw new NotFoundHttpException(Yii::t('yii', 'Page not found.')); } $client = Yii::$app->getRequest()->get('authclient'); if (!Auth::unlinkClient($client)) { Yii::$app->session->addFlash('error', 'Error cant unlink'); } if ($redirectUrl === null) { $redirectUrl = ['/auth/default/profile']; } return $this->redirect($redirectUrl); }