diff --git a/src/Common.CoreLib/DateTimeFormat.cs b/src/Common.CoreLib/DateTimeFormat.cs
index 3f03d7ca6..3b29b39f0 100644
--- a/src/Common.CoreLib/DateTimeFormat.cs
+++ b/src/Common.CoreLib/DateTimeFormat.cs
@@ -1,4 +1,4 @@
-namespace System
+namespace System
{
public static class DateTimeFormat
{
@@ -27,5 +27,7 @@
public const string DateCN = "yyyy年MM月dd日";
public const string DateCN2 = "yyyy年M月d日";
+
+ public const string RFC1123 = "r";
}
}
\ No newline at end of file
diff --git a/src/Common.ServerLib/Extensions/SystemWebExtensions.cs b/src/Common.ServerLib/Extensions/SystemWebExtensions.cs
index 8820b9696..4d1f95307 100644
--- a/src/Common.ServerLib/Extensions/SystemWebExtensions.cs
+++ b/src/Common.ServerLib/Extensions/SystemWebExtensions.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
using System.Net.Sockets;
using System.Text;
@@ -41,6 +42,23 @@ namespace System
.ToString();
}
+ public static string Action(this IUrlHelper helper, string action, QueryString values)
+ {
+ var url = helper.Action(action);
+ if (values.HasValue)
+ {
+ var length = url.Length + values.Value!.Length;
+ return new StringBuilder(length)
+ .Append(url)
+ .Append(values.Value)
+ .ToString();
+ }
+ else
+ {
+ return url;
+ }
+ }
+
///
/// 获取远程客户端的 IP 主机地址
///
diff --git a/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs b/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs
index 0357d7ac9..5693fca77 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/FastLRBHelper.cs
@@ -21,6 +21,10 @@ namespace System.Application.UI.ViewModels
{
public static class FastLRBHelper
{
+#if DEBUG
+ static readonly bool UseLoopbackTest = false;
+#endif
+
public interface IViewModel : IDisposableHolder
{
///
@@ -157,7 +161,7 @@ namespace System.Application.UI.ViewModels
///
///
///
- public static void StartLRB(this IViewModel vm, FastLoginChannel channel)
+ public static async Task StartLRBAsync(this IViewModel vm, FastLoginChannel channel)
{
#if __MOBILE__
switch (channel)
@@ -179,12 +183,10 @@ namespace System.Application.UI.ViewModels
}
vm.ServerWebSocket.Start();
var conn_helper = DI.Get();
- var apiBaseUrl =
-//#if DEBUG
-// "https://127.0.0.1:28110";
-//#else
-ICloudServiceClient.Instance.ApiBaseUrl;
- //#endif
+ var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl;
+#if DEBUG
+ if (UseLoopbackTest) apiBaseUrl = "https://127.0.0.1:28110";
+#endif
vm.TempAes.RemoveTo(vm);
vm.TempAes = AESUtils.Create();
@@ -194,16 +196,18 @@ ICloudServiceClient.Instance.ApiBaseUrl;
var csc = DI.Get();
var padding = RSAUtils.DefaultPadding;
var isBind = vm.IsBind;
- var auth = string.Empty;
+ var access_token = string.Empty;
+ var access_token_expires = string.Empty;
if (isBind)
{
- Func> getAuthTokenAsync = () => conn_helper.Auth.GetAuthTokenAsync().AsTask();
- var authToken = getAuthTokenAsync.RunSync();
+ var authToken = await conn_helper.Auth.GetAuthTokenAsync();
var authHeaderValue = conn_helper.GetAuthenticationHeaderValue(authToken);
if (authHeaderValue != null)
{
var authHeaderValueStr = authHeaderValue.ToString();
- auth = vm.TempAes.Encrypt(authHeaderValueStr);
+ access_token = vm.TempAes.Encrypt(authHeaderValueStr);
+ var now = DateTime.UtcNow;
+ access_token_expires = vm.TempAes.Encrypt(now.ToString(DateTimeFormat.RFC1123));
}
}
var url = apiBaseUrl +
@@ -214,7 +218,8 @@ ICloudServiceClient.Instance.ApiBaseUrl;
$"sKeyPadding={padding.OaepHashAlgorithm}&" +
$"version={csc.Settings.AppVersionStr}&" +
$"isBind={isBind}&" +
- $"auth={auth}";
+ $"access_token_expires={access_token_expires}&" +
+ $"access_token={access_token}";
BrowserOpen(url);
}
}
diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.shared.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.shared.cs
index f61d17a94..171514b16 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.shared.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.shared.cs
@@ -37,13 +37,13 @@ namespace System.Application.UI.ViewModels
#endif
AppResources.LoginAndRegister;
- ChooseChannel = ReactiveCommand.Create(channel_ =>
+ ChooseChannel = ReactiveCommand.CreateFromTask(async channel_ =>
{
if (Enum.TryParse(channel_, out var channel))
{
CurrentSelectChannel = channel_;
ChangeLoginState(3);
- this.StartLRB(channel);
+ await this.StartLRBAsync(channel);
}
#if !__MOBILE__
else
diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.shared.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.shared.cs
index bd0cd98fa..2b35944d0 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.shared.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/UserProfileWindowViewModel.shared.cs
@@ -82,11 +82,11 @@ namespace System.Application.UI.ViewModels
SubscribeFormItem(x => x.AreaSelectItem3, SubscribeAreaOnNext);
SubscribeFormItem(x => x.AreaSelectItem4, SubscribeAreaOnNext);
}
- OnBindFastLoginClick = ReactiveCommand.Create(channel_ =>
+ OnBindFastLoginClick = ReactiveCommand.CreateFromTask(async channel_ =>
{
if (Enum.TryParse(channel_, out var channel))
{
- this.StartLRB(channel);
+ await this.StartLRB(channel);
}
});
OnUnbundleFastLoginClick = ReactiveCommand.CreateFromTask(async channel_ =>