Browse Source

Cli: Check login before suite command

pull/14207/head
Yunus Emre Kalkan 4 years ago
parent
commit
b35a0f7342
  1. 13
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs

13
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 Newtonsoft.Json.Linq;
using NuGet.Versioning; using NuGet.Versioning;
using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Auth;
using Volo.Abp.Cli.Commands.Services; using Volo.Abp.Cli.Commands.Services;
using Volo.Abp.Cli.Http; using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.NuGet; using Volo.Abp.Cli.NuGet;
@ -32,6 +33,7 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency
public ICmdHelper CmdHelper { get; } public ICmdHelper CmdHelper { get; }
private readonly AbpNuGetIndexUrlService _nuGetIndexUrlService; private readonly AbpNuGetIndexUrlService _nuGetIndexUrlService;
private readonly NuGetService _nuGetService; private readonly NuGetService _nuGetService;
private readonly AuthService _authService;
private readonly CliHttpClientFactory _cliHttpClientFactory; private readonly CliHttpClientFactory _cliHttpClientFactory;
private const string SuitePackageName = "Volo.Abp.Suite"; private const string SuitePackageName = "Volo.Abp.Suite";
public ILogger<SuiteCommand> Logger { get; set; } public ILogger<SuiteCommand> Logger { get; set; }
@ -42,17 +44,28 @@ public class SuiteCommand : IConsoleCommand, ITransientDependency
AbpNuGetIndexUrlService nuGetIndexUrlService, AbpNuGetIndexUrlService nuGetIndexUrlService,
NuGetService nuGetService, NuGetService nuGetService,
ICmdHelper cmdHelper, ICmdHelper cmdHelper,
AuthService authService,
CliHttpClientFactory cliHttpClientFactory) CliHttpClientFactory cliHttpClientFactory)
{ {
CmdHelper = cmdHelper; CmdHelper = cmdHelper;
_nuGetIndexUrlService = nuGetIndexUrlService; _nuGetIndexUrlService = nuGetIndexUrlService;
_nuGetService = nuGetService; _nuGetService = nuGetService;
_authService = authService;
_cliHttpClientFactory = cliHttpClientFactory; _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger<SuiteCommand>.Instance; Logger = NullLogger<SuiteCommand>.Instance;
} }
public async Task ExecuteAsync(CommandLineArgs commandLineArgs) 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 operationType = NamespaceHelper.NormalizeNamespace(commandLineArgs.Target);
var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Short) || var preview = commandLineArgs.Options.ContainsKey(Options.Preview.Short) ||

Loading…
Cancel
Save