diff --git a/src/ST.Client.Desktop/Services/Mvvm/UserService.cs b/src/ST.Client.Desktop/Services/Mvvm/UserService.cs index 10ace03f1..a02d229db 100644 --- a/src/ST.Client.Desktop/Services/Mvvm/UserService.cs +++ b/src/ST.Client.Desktop/Services/Mvvm/UserService.cs @@ -262,6 +262,10 @@ namespace System.Application.Services default: return; } + if (user.AvatarUrl != null && user.AvatarUrl.ContainsKey(channel)) + { + user.AvatarUrl.Remove(channel); + } await userManager.SetCurrentUserInfoAsync(user, true); await RefreshUserAsync(user); } @@ -286,6 +290,7 @@ namespace System.Application.Services break; case FastLoginChannel.QQ: user.QQNickName = rsp.User?.QQNickName; + if (string.IsNullOrEmpty(user.NickName)) user.NickName = user.QQNickName ?? ""; break; case FastLoginChannel.Apple: user.AppleAccountEmail = rsp.User?.AppleAccountEmail; @@ -293,6 +298,29 @@ namespace System.Application.Services default: return; } + if (rsp.User != null) + { + if (!string.IsNullOrEmpty(rsp.User.NickName) && string.IsNullOrEmpty(user.NickName)) user.NickName = rsp.User.NickName; + if (rsp.User.Gender != default && user.Gender != rsp.User.Gender) user.Gender = rsp.User.Gender; + if (rsp.User.AvatarUrl != null && rsp.User.AvatarUrl.ContainsKey(channel)) + { + if (user.AvatarUrl == null) + { + user.AvatarUrl = new() + { + { channel, rsp.User.AvatarUrl[channel] } + }; + } + else if (user.AvatarUrl.ContainsKey(channel)) + { + user.AvatarUrl[channel] = rsp.User.AvatarUrl[channel]; + } + else + { + user.AvatarUrl.Add(channel, rsp.User.AvatarUrl[channel]); + } + } + } await userManager.SetCurrentUserInfoAsync(user, true); await RefreshUserAsync(user); } diff --git a/src/ST.Client.Mobile.Droid/UI/Activities/LoginOrRegisterActivity.cs b/src/ST.Client.Mobile.Droid/UI/Activities/LoginOrRegisterActivity.cs index 8ffa92731..9b6c6eb6a 100644 --- a/src/ST.Client.Mobile.Droid/UI/Activities/LoginOrRegisterActivity.cs +++ b/src/ST.Client.Mobile.Droid/UI/Activities/LoginOrRegisterActivity.cs @@ -73,8 +73,6 @@ namespace System.Application.UI.Activities protected override void OnActivityResult(int requestCode, Result resultCode, Intent? data) { - base.OnActivityResult(requestCode, resultCode, data); - var resultCode_ = (int)resultCode; if (requestCode == Com.Tencent.Connect.Common.Constants.RequestLogin) { @@ -84,6 +82,8 @@ namespace System.Application.UI.Activities // Return control to MSAL AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data); + + base.OnActivityResult(requestCode, resultCode, data); } public static SpannableString CreateAgreementAndPrivacy(LoginOrRegisterPageViewModel viewModel) => MainApplication.CreateSpannableString(list => diff --git a/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs b/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs index 7d75ef161..ea60d5f3d 100644 --- a/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs +++ b/src/ST.Services.CloudService.Models/Models/UserInfoDTO.cs @@ -9,6 +9,7 @@ using MPObject = MessagePack.MessagePackObjectAttribute; using N_JsonIgnore = Newtonsoft.Json.JsonIgnoreAttribute; using N_JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; using S_JsonIgnore = System.Text.Json.Serialization.JsonIgnoreAttribute; +using System.Collections.Generic; using S_JsonProperty = System.Text.Json.Serialization.JsonPropertyNameAttribute; namespace System.Application.Models @@ -195,5 +196,22 @@ namespace System.Application.Models #else { get; set; } #endif + + /// + /// 通过快速登录获取的头像URL + /// + [MPKey(18)] + [N_JsonProperty("18")] + [S_JsonProperty("18")] + public Dictionary? AvatarUrl +#if MVVM_VM + { + get => _AvatarUrl; + set => this.RaiseAndSetIfChanged(ref _AvatarUrl, value); + } + Dictionary? _AvatarUrl; +#else + { get; set; } +#endif } } \ No newline at end of file diff --git a/src/ST/FastLoginChannel.cs b/src/ST/FastLoginChannel.cs index d3f9b8282..ce4b16a3c 100644 --- a/src/ST/FastLoginChannel.cs +++ b/src/ST/FastLoginChannel.cs @@ -2,6 +2,18 @@ namespace System.Application { /// /// 快速登录渠道 + /// + /// AuthenticationController.ExternalLogin/ExternalLoginCallback + /// UserManager.LoginSharedAsync + /// UserManager.CreateAccountAsync + /// UserManager.BindAccountAsync + /// UserManager.FindByXAccountIdAsync + /// UserManager.UnbundleAccountAsync + /// IAccountDeleteRecordDbContext.DbSet_XUserTokens + /// ApplicationDbContext.DbSet_XUserTokens/X_Accounts + /// AccountDeleteRecord + /// AccountDeleteRecordRepository.DeleteAccount + /// /// public enum FastLoginChannel {