The `ComputerId` is no longer changed after user changes.

pull/17574/head
maliming 2 years ago
parent 3ac399b6a7
commit 1a4bd9174e
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4

@ -90,8 +90,6 @@ public class AuthService : IAuthService, ITransientDependency
var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration); var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration);
File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8); File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8);
await WriteRandomComputerIdAsync();
} }
public async Task DeviceLoginAsync() public async Task DeviceLoginAsync()
@ -107,8 +105,6 @@ public class AuthService : IAuthService, ITransientDependency
var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration); var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration);
File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8); File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8);
await WriteRandomComputerIdAsync();
} }
public async Task LogoutAsync() public async Task LogoutAsync()
@ -129,8 +125,6 @@ public class AuthService : IAuthService, ITransientDependency
File.Delete(CliPaths.Lic); File.Delete(CliPaths.Lic);
} }
await WriteRandomComputerIdAsync();
} }
public async Task<bool> CheckMultipleOrganizationsAsync(string username) public async Task<bool> CheckMultipleOrganizationsAsync(string username)
@ -183,17 +177,4 @@ public class AuthService : IAuthService, ITransientDependency
{ {
return File.Exists(CliPaths.AccessToken); 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);
}
}
} }

@ -10,7 +10,7 @@ public static class CliPaths
public static string Log => Path.Combine(AbpRootPath, "cli", "logs"); public static string Log => Path.Combine(AbpRootPath, "cli", "logs");
public static string Root => Path.Combine(AbpRootPath, "cli"); public static string Root => Path.Combine(AbpRootPath, "cli");
public static string AccessToken => Path.Combine(AbpRootPath, "cli", "access-token.bin"); 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 Memory => Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!, "memory.bin");
public static string Build => Path.Combine(AbpRootPath, "build"); 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 })); 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 }));

@ -39,15 +39,15 @@ public class CliAnalyticsCollect : ICliAnalyticsCollect, ITransientDependency
{ {
if (input.RandomComputerId.IsNullOrWhiteSpace()) if (input.RandomComputerId.IsNullOrWhiteSpace())
{ {
if (!File.Exists(CliPaths.RandomComputerId)) if (!File.Exists(CliPaths.ComputerId))
{ {
var randomComputerId = Guid.NewGuid().ToString("D"); var randomComputerId = Guid.NewGuid().ToString("D");
input.RandomComputerId = randomComputerId; input.RandomComputerId = randomComputerId;
File.WriteAllText(CliPaths.RandomComputerId, randomComputerId, Encoding.UTF8); File.WriteAllText(CliPaths.ComputerId, randomComputerId, Encoding.UTF8);
} }
else else
{ {
input.RandomComputerId = File.ReadAllText(CliPaths.RandomComputerId, Encoding.UTF8); input.RandomComputerId = File.ReadAllText(CliPaths.ComputerId, Encoding.UTF8);
} }
} }

Loading…
Cancel
Save