service = $service; } public function actions(): array { return [ 'auth' => [ 'class' => AuthAction::class, 'successCallback' => [$this, 'onAuthSuccess'], ], ]; } /** * @param ClientInterface $client * @throws Exception * @throws \Exception */ public function onAuthSuccess(ClientInterface $client): void { $network = $client->getId(); $attributes = $client->getUserAttributes(); $identity = ArrayHelper::getValue($attributes, 'id'); try { $user = $this->service->auth($network, $identity); Yii::$app->user->login(new Identity($user), Yii::$app->params['user.rememberMeDuration']); } catch (DomainException $e) { Yii::$app->errorHandler->logException($e); Yii::$app->session->setFlash('error', $e->getMessage()); } } }