合并微信小程序和支付宝小程序登录入口
This commit is contained in:
@@ -95,7 +95,7 @@ public class LoginFilter implements Filter {
|
||||
return;
|
||||
}
|
||||
|
||||
//environment 环境标识 wx app 后续environment不可为空
|
||||
//environment 环境标识 wx alipay app 后续environment不可为空
|
||||
String environment = request.getHeader("environment");
|
||||
|
||||
// 判断用户TOKEN是否存在
|
||||
@@ -131,7 +131,7 @@ public class LoginFilter implements Filter {
|
||||
String userId = jsonObject1.getString("userId");
|
||||
tokenKey=RedisCst.ONLINE_APP_USER.concat(userId);
|
||||
//获取redis中的token
|
||||
}else if(environment.equals("wx")){
|
||||
}else if(environment.equals("wx") || environment.equals("alipay")){
|
||||
//获取当前登录人的用户id
|
||||
String openId = jsonObject1.getString("openId");
|
||||
if(StringUtils.isBlank(openId)){
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.chaozhanggui.system.cashierservice.alipayUtil.AlipayUtil;
|
||||
@@ -110,18 +109,13 @@ public class LoginContoller {
|
||||
String source = map.getOrDefault("source",AuthSource.WECHAT.getValue());
|
||||
String code = map.get("code");
|
||||
if(AuthSource.WECHAT.getValue().equals(source)){
|
||||
String rawData = map.get("rawData");
|
||||
// 签名:signature
|
||||
JSONObject rawDataJson = JSON.parseObject(rawData);
|
||||
// 1.接收小程序发送的code
|
||||
// 2.开发者服务器 登录凭证校验接口 appi + appsecret + code
|
||||
JSONObject SessionKeyOpenId = WechatUtil.getSessionKeyOrOpenId(code, customAppId, customSecrete);
|
||||
// 3.接收微信接口服务 获取返回的参数
|
||||
String openid = SessionKeyOpenId.getString("openid");
|
||||
String nickName = rawDataJson.getString("nickName");
|
||||
String avatarUrl = rawDataJson.getString("avatarUrl");
|
||||
try {
|
||||
return loginService.wxCustomLogin(openid, avatarUrl, nickName, "", IpUtil.getIpAddr(request));
|
||||
return loginService.wxCustomLogin(openid, "", "", "", IpUtil.getIpAddr(request));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user