From 90993fdad217064b2eb62e5925200fad0fbd0e5b Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 7 Sep 2023 09:19:04 +0800 Subject: [PATCH] The `ComputerId` is no longer changed after user changes. --- .../Volo/Abp/Cli/Auth/AuthService.cs | 19 ------------------- .../Volo/Abp/Cli/CliPaths.cs | 2 +- .../Analyticses/CliAnalyticsCollect.cs | 6 +++--- 3 files changed, 4 insertions(+), 23 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 292b955645..ec2074434a 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 @@ -90,8 +90,6 @@ public class AuthService : IAuthService, ITransientDependency var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration); File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8); - - await WriteRandomComputerIdAsync(); } public async Task DeviceLoginAsync() @@ -107,8 +105,6 @@ public class AuthService : IAuthService, ITransientDependency var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration); File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8); - - await WriteRandomComputerIdAsync(); } public async Task LogoutAsync() @@ -129,8 +125,6 @@ public class AuthService : IAuthService, ITransientDependency File.Delete(CliPaths.Lic); } - - await WriteRandomComputerIdAsync(); } public async Task CheckMultipleOrganizationsAsync(string username) @@ -183,17 +177,4 @@ public class AuthService : IAuthService, ITransientDependency { return File.Exists(CliPaths.AccessToken); } - - private async Task WriteRandomComputerIdAsync() - { - var loginInfo = await GetLoginInfoAsync(); - if (loginInfo != null && loginInfo.Id.HasValue) - { - File.WriteAllText(CliPaths.RandomComputerId, loginInfo.Id.Value.ToString("D"), Encoding.UTF8); - } - else - { - File.WriteAllText(CliPaths.RandomComputerId, Guid.NewGuid().ToString("D"), Encoding.UTF8); - } - } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs index 5153f5285f..d47987b220 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs @@ -10,7 +10,7 @@ public static class CliPaths public static string Log => Path.Combine(AbpRootPath, "cli", "logs"); public static string Root => Path.Combine(AbpRootPath, "cli"); public static string AccessToken => Path.Combine(AbpRootPath, "cli", "access-token.bin"); - public static string RandomComputerId => Path.Combine(AbpRootPath, "cli", "random-computer-id.bin"); + public static string ComputerId => Path.Combine(AbpRootPath, "cli", "computer-id.bin"); public static string Memory => Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!, "memory.bin"); public static string Build => Path.Combine(AbpRootPath, "build"); public static string Lic => Path.Combine(Path.GetTempPath(), Encoding.ASCII.GetString(new byte[] { 65, 98, 112, 76, 105, 99, 101, 110, 115, 101, 46, 98, 105, 110 })); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs index 66568ffb4d..5f504bd407 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs @@ -39,15 +39,15 @@ public class CliAnalyticsCollect : ICliAnalyticsCollect, ITransientDependency { if (input.RandomComputerId.IsNullOrWhiteSpace()) { - if (!File.Exists(CliPaths.RandomComputerId)) + if (!File.Exists(CliPaths.ComputerId)) { var randomComputerId = Guid.NewGuid().ToString("D"); input.RandomComputerId = randomComputerId; - File.WriteAllText(CliPaths.RandomComputerId, randomComputerId, Encoding.UTF8); + File.WriteAllText(CliPaths.ComputerId, randomComputerId, Encoding.UTF8); } else { - input.RandomComputerId = File.ReadAllText(CliPaths.RandomComputerId, Encoding.UTF8); + input.RandomComputerId = File.ReadAllText(CliPaths.ComputerId, Encoding.UTF8); } }