xieb
2023-10-19 1dd5d8f8a616f5cf3caa7828d46989c7d3dcafc4
skjcmanager/skjcmanager-auth/src/main/java/cn/gistack/auth/endpoint/BladeTokenEndPoint.java
@@ -62,7 +62,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import static cn.gistack.common.cache.CacheNames.OAUTH_KEY;
import static cn.gistack.common.cache.CacheNames.*;
import static org.springblade.core.cache.constant.CacheConstant.*;
/**
@@ -103,7 +103,11 @@
   @SneakyThrows
   @GetMapping("/oauth/tokenLoginUI")
   public void tokenLoginUI(HttpServletResponse response, String code) {
      response.sendRedirect(oauthProperties.getRedirectWebUri() + "?code=" + code);
      if (StringUtil.isBlank(code)) {
         response.sendRedirect(oauthProperties.getRedirectExitUri());
      } else {
         response.sendRedirect(oauthProperties.getRedirectWebUri() + "?code=" + code);
      }
   }
   @GetMapping("/oauth/tokenLogin")
@@ -156,6 +160,8 @@
      String url = WX_GET_PHONE_NUMBER + "?access_token=" + wxAccessToken;
      //向微信接口发起请求获取手机号
      RestTemplate template = new RestTemplate();
      Map<String, Object> params = new LinkedHashMap<>();
      params.put("code", code);
@@ -163,6 +169,10 @@
      JSONObject resultObj = (JSONObject) JSONObject.parse(result);
      JSONObject phoneInfo = (JSONObject) resultObj.get("phone_info");
      String phoneNumber = phoneInfo.get("phoneNumber").toString();
      //把code存入redis作为登录标识(有效时长300秒)
      bladeRedis.setEx(WX_KEY + phoneNumber,code,5*60L);
      R<User> userR = userClient.userByAccount("000000", phoneNumber);
      if (userR.getData() != null) {
         return R.data(phoneNumber);