/** * Returns the user object which is linked against given authClient * * @param ClientInterface $authClient the authClient * @return User the user model or null if not found */ public static function getUserByAuthClient(ClientInterface $authClient) { $attributes = $authClient->getUserAttributes(); if ($authClient instanceof interfaces\PrimaryClient) { /** * @var interfaces\PrimaryClient $authClient */ return User::findOne([$authClient->getUserTableIdAttribute() => $attributes['id'], 'auth_mode' => $authClient->getId()]); } $auth = Auth::find()->where(['source' => $authClient->getId(), 'source_id' => $attributes['id']])->one(); if ($auth !== null) { return $auth->user; } }