From 04bd24b1faf7419547d1609b9eecb27fae910856 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期一, 11 八月 2025 17:33:17 +0800 Subject: [PATCH] feat:开发 --- FlexJobApi.UserServer.Application/Auths/Commands/LoginCommandHandler.cs | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/FlexJobApi.UserServer.Application/Auths/Commands/LoginCommandHandler.cs b/FlexJobApi.UserServer.Application/Auths/Commands/LoginCommandHandler.cs index c66b6d4..7685bd3 100644 --- a/FlexJobApi.UserServer.Application/Auths/Commands/LoginCommandHandler.cs +++ b/FlexJobApi.UserServer.Application/Auths/Commands/LoginCommandHandler.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Claims; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; @@ -85,6 +86,10 @@ /// <returns></returns> public async Task<LoginCommandCallback> Handle(WxmpLoginCommand request, CancellationToken cancellationToken) { + if (request.Type == EnumUserType.Operation) + { + throw Oops.Oh(EnumErrorCodeType.s400, "涓嶆敮鎸佽绫诲瀷璐﹀彿鐧诲綍"); + } var snsJscode2session = await wxmpUtils.SnsJscode2sessionAsync(request.Type, request.Code, cancellationToken); var user = await rep.AsQueryable().AsNoTracking() .Where(it => it.WxmpOpenId == snsJscode2session.openid && it.Type == request.Type) @@ -148,9 +153,15 @@ /// <exception cref="NotImplementedException"></exception> public async Task<LoginCommandCallback> Handle(BindWxmpUserInfoCommand request, CancellationToken cancellationToken) { - var logier = JwtUtils.GetCurrentLogier(); + var claims = JWTEncryption.ReadJwtToken(request.AccessToken).Claims; + var claimIdentity = new ClaimsIdentity("AuthenticationTypes.Federation"); + claimIdentity.AddClaims(claims); + var claimsPrincipal = new ClaimsPrincipal(claimIdentity); + var id = claimsPrincipal.FindFirstValue("Id").ToGuid(); + var type = claimsPrincipal.FindFirstValue("Type").ToEnum<EnumUserType>(); + var user = await rep.AsQueryable() - .Where(it => it.Type == logier.Type && it.Id == logier.Id) + .Where(it => it.Type == type && it.Id == id) .FirstOrDefaultAsync(cancellationToken); if (user == null) throw Oops.Oh(EnumErrorCodeType.s404, "褰撳墠璐﹀彿"); if (user.WxmpOpenId.IsNull()) throw Oops.Oh(EnumUserErrorCodeType.u1100); @@ -183,10 +194,14 @@ } var bindPhoneNumberUser = await rep.AsQueryable() - .Where(it => it.Type == logier.Type && it.PhoneNumber == info.PhoneNumber && it.Id != user.Id) + .Where(it => it.Type == type && it.PhoneNumber == info.PhoneNumber && it.Id != user.Id) .FirstOrDefaultAsync(cancellationToken); if (bindPhoneNumberUser == null) { + if (type == EnumUserType.Enterprise) + { + throw Oops.Oh(EnumErrorCodeType.s404, "璇ヨ处鍙�"); + } user.PhoneNumber = info.PhoneNumber; user.ContactPhoneNumber = info.PhoneNumber; user.IsCheckPhoneNumber = true; -- Gitblit v1.9.1