From d75be8224aa2bd8c0feb37e4e4e886a9b8c425e0 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 10 Feb 2023 11:38:14 +0300 Subject: [PATCH] Cli: Add CheckMultipleOrganizationsAsync to IAuthService --- .../Volo/Abp/Cli/Auth/AuthService.cs | 40 +++++++++---------- .../Volo/Abp/Cli/Auth/IAuthService.cs | 2 + 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs index 72bac8d494..6e5ea8d222 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs @@ -127,6 +127,26 @@ public class AuthService : IAuthService, ITransientDependency } } + public async Task CheckMultipleOrganizationsAsync(string username) + { + var url = $"{CliUrls.WwwAbpIo}api/license/check-multiple-organizations?username={username}"; + + var client = CliHttpClientFactory.CreateClient(); + + using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger)) + { + if (!response.IsSuccessStatusCode) + { + throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'"); + } + + await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response); + + var responseContent = await response.Content.ReadAsStringAsync(); + return JsonSerializer.Deserialize(responseContent); + } + } + private async Task LogoutAsync(string accessToken) { try @@ -153,26 +173,6 @@ public class AuthService : IAuthService, ITransientDependency } } - public async Task CheckMultipleOrganizationsAsync(string username) - { - var url = $"{CliUrls.WwwAbpIo}api/license/check-multiple-organizations?username={username}"; - - var client = CliHttpClientFactory.CreateClient(); - - using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger)) - { - if (!response.IsSuccessStatusCode) - { - throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'"); - } - - await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response); - - var responseContent = await response.Content.ReadAsStringAsync(); - return JsonSerializer.Deserialize(responseContent); - } - } - public static bool IsLoggedIn() { return File.Exists(CliPaths.AccessToken); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/IAuthService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/IAuthService.cs index ad2916ca0b..f91fd0dc00 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/IAuthService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/IAuthService.cs @@ -9,4 +9,6 @@ public interface IAuthService Task LoginAsync(string userName, string password, string organizationName = null); Task LogoutAsync(); + + Task CheckMultipleOrganizationsAsync(string username); }