//注册志愿者时 验证用户是否是 微官网用户 public virtual WeChatUserCheckResModel CheckUser(string unionid) { WeChatUserCheckResModel userInfoCheck = new WeChatUserCheckResModel(); var predicate = WhereExtension.True <UserInfo>(); predicate = predicate.And(p => p.unionid.Contains(unionid)); predicate = predicate.And(p => !String.IsNullOrEmpty(p.Mobile)); var result = WGWDbSet.Where(predicate); if (result.Count() > 0) { userInfoCheck.ID = result.First().ID; userInfoCheck.unionId = result.First().unionid; userInfoCheck.nickName = result.First().nickname; } return(userInfoCheck); }
/// <summary> /// 根据微信小程序平台提供的解密算法解密数据,推荐直接使用此方法 /// </summary> /// <param name="codeModel">登陆信息</param> /// <returns>用户信息</returns> public WeChatUserCheckResModel Decrypt(WeChatCodeModel codeModel, string appId, string appSecret) { WeChatUserCheckResModel userInfoCheck = new WeChatUserCheckResModel(); if (codeModel == null) { return(null); } if (String.IsNullOrEmpty(codeModel.code)) { return(null); } WeChatInfoModel oiask = JsonConvert.DeserializeObject <WeChatInfoModel>(GetOpenIdAndSessionKeyString(codeModel.code, appId, appSecret)); userInfoCheck = CheckUser(oiask.unionid); return(userInfoCheck); }
public ActionResult <WeChatUserCheckResModel> CheckWeChartUserInfo(WeChatCodeModel codeModel) { WeChatUserCheckResModel resModel = _weChatHttpClientService.GetWeChartInfo(codeModel); return(resModel); }
/// <summary> /// 用户初次进入自愿者小程序验证用户是否是微官网已注册用户,如果是返回微官网用户中心ID,如果不是返回空 /// </summary> public WeChatUserCheckResModel GetWeChartInfo(WeChatCodeModel codeModel) { WeChatUserCheckResModel result = _IWeChatClientRepository.Decrypt(codeModel, _IOptions.Value.appid, _IOptions.Value.secret); return(result); }