| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Security.Claims; |
| | | using System.Security.Cryptography; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | /// <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); |
| | |
| | | } |
| | | |
| | | 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 (logier.Type == EnumUserType.Enterprise) |
| | | if (type == EnumUserType.Enterprise) |
| | | { |
| | | throw Oops.Oh(EnumErrorCodeType.s404, "该账号"); |
| | | } |