新增 QQ 登录渠道,修复 第三方账号绑定或登录时的个人资料没有同步显示

This commit is contained in:
Aigio Liu
2021-07-01 20:19:33 +08:00
parent 868143a248
commit fe000c95b6
4 changed files with 60 additions and 2 deletions
@@ -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);
}
@@ -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 =>
@@ -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
/// <summary>
/// 通过快速登录获取的头像URL
/// </summary>
[MPKey(18)]
[N_JsonProperty("18")]
[S_JsonProperty("18")]
public Dictionary<FastLoginChannel, string>? AvatarUrl
#if MVVM_VM
{
get => _AvatarUrl;
set => this.RaiseAndSetIfChanged(ref _AvatarUrl, value);
}
Dictionary<FastLoginChannel, string>? _AvatarUrl;
#else
{ get; set; }
#endif
}
}
+12
View File
@@ -2,6 +2,18 @@ namespace System.Application
{
/// <summary>
/// 快速登录渠道
/// <list type="bullet">
/// <item>AuthenticationController.ExternalLogin/ExternalLoginCallback</item>
/// <item>UserManager.LoginSharedAsync</item>
/// <item>UserManager.CreateAccountAsync</item>
/// <item>UserManager.BindAccountAsync</item>
/// <item>UserManager.FindByXAccountIdAsync</item>
/// <item>UserManager.UnbundleAccountAsync</item>
/// <item>IAccountDeleteRecordDbContext.DbSet_XUserTokens</item>
/// <item>ApplicationDbContext.DbSet_XUserTokens/X_Accounts</item>
/// <item>AccountDeleteRecord</item>
/// <item>AccountDeleteRecordRepository.DeleteAccount</item>
/// </list>
/// </summary>
public enum FastLoginChannel
{