/// <summary> /// 开始第三方快速登录、注册、绑定 /// </summary> /// <param name="vm"></param> /// <param name="channel"></param> /// <returns></returns> public static async Task StartAsync(WindowViewModel vm, FastLoginChannel channel, bool isBind) { var app = IApplication.Instance; StartServer(app); var conn_helper = DI.Get <IApiConnectionPlatformHelper>(); var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl; #if DEBUG if (UseLoopbackTest) { apiBaseUrl = "https://127.0.0.1:28110"; } #endif ThirdPartyLoginHelper.isBind = isBind; ThirdPartyLoginHelper.vm = vm; Disposable.Create(() => { if (vm == ThirdPartyLoginHelper.vm) { ThirdPartyLoginHelper.vm = null; } }).AddTo(vm); if (tempAes == null) { tempAes = AESUtils.Create(); // 每次创建新的之前的会失效 } var skey_bytes = tempAes.ToParamsByteArray(); var skey_str = conn_helper.RSA.EncryptToString(skey_bytes); var csc = DI.Get <CloudServiceClientBase>(); var padding = RSAUtils.DefaultPadding; var access_token = string.Empty; var access_token_expires = string.Empty; if (isBind) { var authToken = await conn_helper.Auth.GetAuthTokenAsync(); var authHeaderValue = conn_helper.GetAuthenticationHeaderValue(authToken); if (authHeaderValue != null) { var authHeaderValueStr = authHeaderValue.ToString(); access_token = tempAes.Encrypt(authHeaderValueStr); var now = DateTime.UtcNow; access_token_expires = tempAes.Encrypt(now.ToString(DateTimeFormat.RFC1123)); } } // &version={version} //var version = csc.Settings.AppVersionStr; var ver = _ThisAssembly.Version.Base64UrlEncode(); var url = $"{apiBaseUrl}/ExternalLoginDetection/{(int)channel}?port={port}&sKey={skey_str}&sKeyPadding={padding.OaepHashAlgorithm}&ver={ver}&isBind={isBind}&access_token_expires={access_token_expires}&access_token={access_token}"; await Browser2.OpenAsync(url); }
internal static Task FastLoginOrRegisterAsync(Action?close = null, FastLoginChannel channel = FastLoginChannel.Steam, bool isBind = false) { switch (channel) { case FastLoginChannel.Microsoft: MicrosoftFastLoginOrRegister();
public static string GetIsBindOrUnbundleBtnText(FastLoginChannel channel) => IsBindOrUnbundle(channel) ? AppResources.Bind : AppResources.Unbundling;
public static bool IsBindOrUnbundle(FastLoginChannel channel) => channel switch {
public static ResIcon ToIcon(this FastLoginChannel fastLoginChannel) => fastLoginChannel switch {
/// <summary> /// 当前快速登录渠道是否已支持 /// </summary> /// <param name="fastLoginChannel"></param> /// <returns></returns> public static bool IsSupported(this FastLoginChannel fastLoginChannel) #if DEBUG => true;