From b35a0f7342c7379b13e7b5b6bb2904ee254f9dd5 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 3 Oct 2022 14:48:01 +0300 Subject: [PATCH] Cli: Check login before suite command --- .../Volo/Abp/Cli/Commands/SuiteCommand.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs index 060262eb93..f1aebafc64 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Newtonsoft.Json.Linq; using NuGet.Versioning; using Volo.Abp.Cli.Args; +using Volo.Abp.Cli.Auth; using Volo.Abp.Cli.Commands.Services; using Volo.Abp.Cli.Http; using Volo.Abp.Cli.NuGet; @@ -32,6 +33,7 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency public ICmdHelper CmdHelper { get; } private readonly AbpNuGetIndexUrlService _nuGetIndexUrlService; private readonly NuGetService _nuGetService; + private readonly AuthService _authService; private readonly CliHttpClientFactory _cliHttpClientFactory; private const string SuitePackageName = "Volo.Abp.Suite"; public ILogger Logger { get; set; } @@ -42,17 +44,28 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency AbpNuGetIndexUrlService nuGetIndexUrlService, NuGetService nuGetService, ICmdHelper cmdHelper, + AuthService authService, CliHttpClientFactory cliHttpClientFactory) { CmdHelper = cmdHelper; _nuGetIndexUrlService = nuGetIndexUrlService; _nuGetService = nuGetService; + _authService = authService; _cliHttpClientFactory = cliHttpClientFactory; Logger = NullLogger.Instance; } public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { +#if !DEBUG + var loginInfo = await _authService.GetLoginInfoAsync(); + + if (string.IsNullOrEmpty(loginInfo.Organization)) + { + throw new CliUsageException("Please login with your account."); + } +#endif + var operationType = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target); var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Short) ||