Commit 1f661d79 authored by hezhen's avatar hezhen

123

parent cd942b0e
package com.xxfc.platform.universal.biz; package com.xxfc.platform.universal.biz;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
...@@ -78,7 +79,8 @@ public class WeixinService { ...@@ -78,7 +79,8 @@ public class WeixinService {
if (StringUtils.isBlank(frontSessionValue1)) { if (StringUtils.isBlank(frontSessionValue1)) {
return null; return null;
} }
return frontSessionValue1; String openId = Base64.decodeStr(frontSessionValue1);
return openId;
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return null; return null;
......
...@@ -31,6 +31,7 @@ public class WeixinController { ...@@ -31,6 +31,7 @@ public class WeixinController {
public static final String WECHAT_AUTOLOGIN_CALLBACKURL_KEY = "callback"; public static final String WECHAT_AUTOLOGIN_CALLBACKURL_KEY = "callback";
public static final String frontSessionKey = "frontWeixKey";
@Autowired @Autowired
WeixinService weixinService; WeixinService weixinService;
...@@ -70,7 +71,7 @@ public class WeixinController { ...@@ -70,7 +71,7 @@ public class WeixinController {
public String getUserInformation(String code, String callback, HttpServletRequest request) { public String getUserInformation(String code, String callback, HttpServletRequest request) {
log.info("-----微信回调userInfo---code=="+code+"----redirec_url==="+callback); log.info("-----微信回调userInfo---code=="+code+"----redirec_url==="+callback);
try { try {
authUser(code); authUser(code,request);
callback =new String(Base64.decode(callback), "utf-8"); callback =new String(Base64.decode(callback), "utf-8");
log.info("callback===" + callback); log.info("callback===" + callback);
}catch (Exception e){ }catch (Exception e){
...@@ -82,7 +83,7 @@ public class WeixinController { ...@@ -82,7 +83,7 @@ public class WeixinController {
public void authUser(String code){ public void authUser(String code,HttpServletRequest request){
if (StringUtils.isBlank(code)){ if (StringUtils.isBlank(code)){
log.info("----code为空---"); log.info("----code为空---");
throw new BaseException(ResultCode.FAILED_CODE, Sets.newSet("code为空")); throw new BaseException(ResultCode.FAILED_CODE, Sets.newSet("code为空"));
...@@ -102,6 +103,10 @@ public class WeixinController { ...@@ -102,6 +103,10 @@ public class WeixinController {
JSONObject refreshData= weixinService.getRefreshToken(refresh_token); JSONObject refreshData= weixinService.getRefreshToken(refresh_token);
access_token = refreshData.getString("access_token"); access_token = refreshData.getString("access_token");
} }
String encode = Base64.encode(openid);
HttpSession session = request.getSession();
session.removeAttribute(frontSessionKey);
session.setAttribute(frontSessionKey, encode);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
log.info("网络异常===" + e.getMessage()); log.info("网络异常===" + e.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment