Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cli incorrect license error and warning #2635

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ public Task LogoutAsync()
FileHelper.DeleteIfExists(CliPaths.AccessToken);
return Task.CompletedTask;
}

public static bool IsLoggedIn()
{
return File.Exists(CliPaths.AccessToken);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Net.Http;
using System.Text;
using IdentityModel.Client;
using Volo.Abp.Cli.Auth;

namespace Volo.Abp.Cli.Http
{
Expand All @@ -29,7 +30,7 @@ public CliHttpClient(bool setBearerToken) : base(new CliHttpClientHandler())

private static void AddAuthentication(HttpClient client)
{
if (!File.Exists(CliPaths.AccessToken))
if (!AuthService.IsLoggedIn())
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.Logging.Abstractions;
using Polly;
using Polly.Extensions.Http;
using Volo.Abp.Cli.Auth;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.DependencyInjection;
Expand All @@ -31,6 +32,11 @@ public AbpIoApiKeyService(IJsonSerializer jsonSerializer, IRemoteServiceExceptio

public async Task<DeveloperApiKeyResult> GetApiKeyOrNullAsync(bool invalidateCache = false)
{
if (!AuthService.IsLoggedIn())
{
return null;
}

if (invalidateCache)
{
_apiKeyResult = null;
Expand Down Expand Up @@ -81,16 +87,6 @@ public async Task<DeveloperApiKeyResult> GetApiKeyOrNullAsync(bool invalidateCac
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
var apiKeyResult = JsonSerializer.Deserialize<DeveloperApiKeyResult>(responseContent);

if (string.IsNullOrEmpty(apiKeyResult?.ApiKey))
{
_logger.LogError("Couldn't retrieve your NuGet API key!");
_logger.LogWarning(File.Exists(CliPaths.AccessToken)
? "Make sure you have an active session and license on commercial.abp.io. To re-sign in you can use the CLI command \"abp login <username>\"."
: "You are not signed in to commercial.abp.io. Use the CLI command \"abp login <username>\" to sign in.");

return null;
}

return apiKeyResult;
}
}
Expand Down