【修复】修复可能存在一个用户多个微信号绑定一个手机号码,导致openid不同而支付提示【下单账号与支付账号不一致,请核实后再支付】的问题。

This commit is contained in:
jianweie code
2024-06-19 10:33:02 +08:00
parent d464f953ef
commit 79e15fdeb1
4 changed files with 11 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ namespace CoreCms.Net.Auth.HttpContextUser
public string Name => _accessor.HttpContext.User.Identity.Name;
public int ID => GetClaimValueByType("jti").FirstOrDefault().ObjectToInt();
public string OpenId => GetClaimValueByType("nameid").FirstOrDefault();
public bool IsAuthenticated()
{

View File

@@ -19,6 +19,7 @@ namespace CoreCms.Net.Auth.HttpContextUser
{
string Name { get; }
int ID { get; }
string OpenId { get; }
bool IsAuthenticated();
IEnumerable<Claim> GetClaimsIdentity();
List<string> GetClaimValueByType(string ClaimType);

View File

@@ -121,8 +121,15 @@ namespace CoreCms.Net.Services
return jm;
}
if (!string.IsNullOrEmpty(_user.OpenId) && _user.OpenId != user.openid)
{
openId = _user.OpenId;
}
else
{
openId = user.openid;
}
openId = user.openid;
}
var notifyUrl = config.notifyUrl.EndsWith("/") ? config.notifyUrl + "m-" + config.appId : config.notifyUrl + "/m-" + config.appId;

View File

@@ -248,6 +248,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var claims = new List<Claim> {
new Claim(ClaimTypes.Name, user.nickName),
new Claim(JwtRegisteredClaimNames.Jti, user.id.ToString()),
new Claim(JwtRegisteredClaimNames.NameId, response.OpenId),
new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(_permissionRequirement.Expiration.TotalSeconds).ToString(CultureInfo.InvariantCulture)) };
//用户标识