runWithConfig method

  1. @override
Future<void> runWithConfig(
  1. Configuration<LoginCommandOption> commandConfig
)
override

Runs this command with prepared configuration (options). Subclasses should override this method.

Implementation

@override
Future<void> runWithConfig(
  final Configuration<LoginCommandOption> commandConfig,
) async {
  final timeLimit = commandConfig.value(LoginCommandOption.timeoutOpt);
  final signInPath = commandConfig.value(LoginCommandOption.signinPathOpt);
  final persistent = commandConfig.value(LoginCommandOption.persistentOpt);
  final openBrowser = commandConfig.value(LoginCommandOption.browserOpt);

  final localStoragePath = globalConfiguration.scloudDir;

  final storedCloudData =
      await ResourceManager.tryFetchServerpodCloudAuthData(
        localStoragePath: localStoragePath.path,
        logger: logger,
      );

  if (storedCloudData != null) {
    logger.error(
      'Detected an existing login session for Serverpod cloud. '
      'Log out first to log in again.',
    );
    logger.terminalCommand('scloud auth logout');
    throw FailureException();
  }

  await AuthLoginCommands.login(
    logger: logger,
    globalConfig: globalConfiguration,
    timeLimit: timeLimit,
    persistent: persistent,
    openBrowser: openBrowser,
    signInPath: signInPath,
  );
}