|
@@ -1,38 +1,27 @@
|
|
|
package com.cyksj.web.controller.user;
|
|
package com.cyksj.web.controller.user;
|
|
|
|
|
|
|
|
-import cn.hutool.core.codec.Base64;
|
|
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.EnvCommonService;
|
|
import com.cyksj.common.EnvCommonService;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.i18n.I18nMessageUtil;
|
|
import com.cyksj.common.i18n.I18nMessageUtil;
|
|
|
-import com.cyksj.common.snowflake.Sequence;
|
|
|
|
|
-import com.cyksj.common.util.*;
|
|
|
|
|
-import com.cyksj.config.WeChatConfig;
|
|
|
|
|
-import com.cyksj.config.wxlogin.WxOpenPlatYHLXLoginConfig;
|
|
|
|
|
|
|
+import com.cyksj.common.util.BlackOpsUtil;
|
|
|
|
|
+import com.cyksj.common.util.SmsUtil;
|
|
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.PhoneCodeMapper;
|
|
import com.cyksj.mapper.PhoneCodeMapper;
|
|
|
-import com.cyksj.model.dto.AuthRedirect;
|
|
|
|
|
-import com.cyksj.model.dto.AuthToken;
|
|
|
|
|
-import com.cyksj.model.dto.GzhOAuth2UserInfo;
|
|
|
|
|
-import com.cyksj.model.dto.JsSdkTicket;
|
|
|
|
|
import com.cyksj.model.entity.PhoneCode;
|
|
import com.cyksj.model.entity.PhoneCode;
|
|
|
import com.cyksj.model.entity.User;
|
|
import com.cyksj.model.entity.User;
|
|
|
import com.cyksj.model.request.EmailFeedBackReq;
|
|
import com.cyksj.model.request.EmailFeedBackReq;
|
|
|
import com.cyksj.model.request.LoginReq;
|
|
import com.cyksj.model.request.LoginReq;
|
|
|
import com.cyksj.model.response.UserAuthLoginResp;
|
|
import com.cyksj.model.response.UserAuthLoginResp;
|
|
|
-import com.cyksj.model.response.WxGzhQrCodeTicketRep;
|
|
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
-import com.cyksj.service.authorization.AuthorizationService;
|
|
|
|
|
import com.cyksj.service.mail.MailService;
|
|
import com.cyksj.service.mail.MailService;
|
|
|
-import com.cyksj.service.template.TemplateCommonService;
|
|
|
|
|
import com.cyksj.service.user.BadIntentionOpService;
|
|
import com.cyksj.service.user.BadIntentionOpService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
import com.cyksj.service.user.UserService;
|
|
|
-import com.cyksj.service.wechat.WeChatService;
|
|
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
|
|
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
|
|
|
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
|
|
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;
|
|
@@ -40,17 +29,11 @@ import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
|
|
import com.google.api.client.json.gson.GsonFactory;
|
|
import com.google.api.client.json.gson.GsonFactory;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import javax.servlet.http.Cookie;
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
-import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author chan
|
|
* @author chan
|
|
@@ -63,256 +46,21 @@ import java.util.Optional;
|
|
|
@RequestMapping("/auth")
|
|
@RequestMapping("/auth")
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
public class AuthorizationController {
|
|
public class AuthorizationController {
|
|
|
-
|
|
|
|
|
- private final static Sequence SEQUENCE = new Sequence(0);
|
|
|
|
|
-
|
|
|
|
|
- private final HttpServletRequest request;
|
|
|
|
|
-
|
|
|
|
|
- private final AuthorizationService authorizationService;
|
|
|
|
|
-
|
|
|
|
|
private final UserService userService;
|
|
private final UserService userService;
|
|
|
|
|
|
|
|
- private final WeChatService weChatService;
|
|
|
|
|
-
|
|
|
|
|
- private final WeChatConfig weChatConfig;
|
|
|
|
|
-
|
|
|
|
|
private final RedisService redisService;
|
|
private final RedisService redisService;
|
|
|
|
|
|
|
|
private final BadIntentionOpService badIntentionOpService;
|
|
private final BadIntentionOpService badIntentionOpService;
|
|
|
|
|
|
|
|
- private final WxOpenPlatYHLXLoginConfig wxOpenPlatYHLXLoginConfig;
|
|
|
|
|
-
|
|
|
|
|
private final EnvCommonService envCommonService;
|
|
private final EnvCommonService envCommonService;
|
|
|
|
|
|
|
|
private final PhoneCodeMapper phoneCodeMapper;
|
|
private final PhoneCodeMapper phoneCodeMapper;
|
|
|
|
|
|
|
|
private final MailService mailService;
|
|
private final MailService mailService;
|
|
|
|
|
|
|
|
- private final TemplateCommonService templateCommonService;
|
|
|
|
|
-
|
|
|
|
|
@Value("${google.clientId}")
|
|
@Value("${google.clientId}")
|
|
|
private String clientId;
|
|
private String clientId;
|
|
|
|
|
|
|
|
- @GetMapping(value = "/weChat")
|
|
|
|
|
- public void base(String url, String dsCode, Long sharedId, Integer dsType, Long popularizeId, String authType, String callbackType, String callback, HttpServletResponse response) throws Exception {
|
|
|
|
|
-
|
|
|
|
|
- log.info("微信授权转跳. url: {},authType:{}", url, authType);
|
|
|
|
|
-
|
|
|
|
|
- // 无论是否为老用户 均转跳到授权页面
|
|
|
|
|
- // 若授权过 则无需再次授权 直接回调 /user/wechat/redirect
|
|
|
|
|
- // 新用户同意授权后 也会回调 /user/wechat/redirect
|
|
|
|
|
-
|
|
|
|
|
- Long mappingId = SEQUENCE.nextId();
|
|
|
|
|
- redisService.set(mappingId.toString(), url, 60 * 60 * 24L);
|
|
|
|
|
- if (StrUtil.isNotBlank(dsCode)) {
|
|
|
|
|
- dsCode = dsCode.trim();
|
|
|
|
|
- }
|
|
|
|
|
- AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setDsCode(dsCode)
|
|
|
|
|
- .setCk(callback)
|
|
|
|
|
- .setCt(callbackType);
|
|
|
|
|
- String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
|
|
|
-
|
|
|
|
|
- response.sendRedirect(authorizationService.createUrl(state, authType));
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 全量授权
|
|
|
|
|
- *
|
|
|
|
|
- * @author chan
|
|
|
|
|
- * @date 2021-10-11 上午11:57
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping(value = "/weChat/baseRedirect")
|
|
|
|
|
- public void redirect(String code, String state, HttpServletResponse response) throws Exception {
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code, weChatConfig.getAppid());
|
|
|
|
|
-
|
|
|
|
|
- baseRedirect(token, state, User.RegisterEnv.wx, response);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 静默授权
|
|
|
|
|
- *
|
|
|
|
|
- * @author chan
|
|
|
|
|
- * @date 2021-10-11 上午11:58
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/weChat/silentRedirect")
|
|
|
|
|
- @Transactional(rollbackFor = Throwable.class)
|
|
|
|
|
- public void redirectV2(String code, String state, HttpServletResponse response) throws Exception {
|
|
|
|
|
-
|
|
|
|
|
- // 转跳参数
|
|
|
|
|
- String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
|
|
- AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
|
|
-
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code, weChatConfig.getAppid());
|
|
|
|
|
-
|
|
|
|
|
- // 查询用户期望转跳的url
|
|
|
|
|
- String url = redisService.getStr(re.getMappingId().toString());
|
|
|
|
|
- String data = Codec.DoBase64.custom().setData(token.getOpenid()).encodeAsText();
|
|
|
|
|
-
|
|
|
|
|
- Cookie cookie = new Cookie("openKey", data);
|
|
|
|
|
- cookie.setMaxAge(31536000);
|
|
|
|
|
- cookie.setPath("/");
|
|
|
|
|
- response.addCookie(cookie);
|
|
|
|
|
-
|
|
|
|
|
- log.info("微信授权转跳. url: {}", url);
|
|
|
|
|
- response.sendRedirect(url);
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 微信js-sdk 权限验证
|
|
|
|
|
- */
|
|
|
|
|
- @RequestMapping(value = "/jsTicket", method = RequestMethod.GET)
|
|
|
|
|
- public Result<JsSdkTicket> ticket(String appId, String url) throws Exception {
|
|
|
|
|
- if (StringUtils.isBlank(url)) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("请输入授权网址.");
|
|
|
|
|
- }
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(authorizationService.getJsTicket(Optional.ofNullable(appId).orElse(weChatConfig.getAppid()), url));
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //public Result<String> login(String phone, String code){
|
|
|
|
|
- //
|
|
|
|
|
- // //
|
|
|
|
|
- // ////保存用户信息
|
|
|
|
|
- // //User user = userService.saveAuth(userinfo);
|
|
|
|
|
- // //
|
|
|
|
|
- // //
|
|
|
|
|
- // ////写回登陆信息
|
|
|
|
|
- // //StpUserUtil.login(user.getId());
|
|
|
|
|
- // //response.addHeader("satoken",StpUserUtil.getTokenValue());
|
|
|
|
|
- // //
|
|
|
|
|
- // //Cookie cookie = new Cookie("satoken",StpUserUtil.getTokenValue());
|
|
|
|
|
- // //cookie.setMaxAge(31536000);
|
|
|
|
|
- // //cookie.setPath("/");
|
|
|
|
|
- // //response.addCookie(cookie);
|
|
|
|
|
- // //JSONObject jsonObject = new JSONObject();
|
|
|
|
|
- // //jsonObject.putOpt("uid",user.getId());
|
|
|
|
|
- // //jsonObject.putOpt("nickName",user.getNickname());
|
|
|
|
|
- // //
|
|
|
|
|
- // //Cookie userInfo = new Cookie("info",Base64.encode(jsonObject.toString()));
|
|
|
|
|
- // //cookie.setMaxAge(31536000);
|
|
|
|
|
- // //cookie.setPath("/");
|
|
|
|
|
- // //response.addCookie(userInfo);
|
|
|
|
|
- // //
|
|
|
|
|
- // //String url = redisService.getStr(re.getMappingId().toString());
|
|
|
|
|
- // //redisService.del(re.getMappingId().toString());
|
|
|
|
|
- // //log.info("微信授权转跳.url: {}",url);
|
|
|
|
|
- // //response.sendRedirect(url);
|
|
|
|
|
- //
|
|
|
|
|
- //}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 网页微信授权登录
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/authLogin")
|
|
|
|
|
- public Result<String> wxAuthorize(Long sharedId, Integer dsType, Long popularizeId, String dsCode, String type, String callbackType, String callback) throws Exception {
|
|
|
|
|
- Long mappingId = SEQUENCE.nextId();
|
|
|
|
|
- String loginUrl = wxOpenPlatYHLXLoginConfig.getLoginUrl();
|
|
|
|
|
- if (StrUtil.isNotBlank(type)) {
|
|
|
|
|
- loginUrl = String.format("https://nf.video/%s/web", type);
|
|
|
|
|
- }
|
|
|
|
|
- redisService.set(mappingId.toString(), loginUrl, 60 * 60 * 24L);
|
|
|
|
|
- if (StrUtil.isNotBlank(dsCode)) {
|
|
|
|
|
- dsCode = dsCode.trim();
|
|
|
|
|
- }
|
|
|
|
|
- AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId).setSharedId(sharedId).setDsType(dsType).setPid(popularizeId).setDsCode(dsCode)
|
|
|
|
|
- .setCk(callback)
|
|
|
|
|
- .setCt(callbackType);
|
|
|
|
|
- String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
|
|
|
- String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getRedirectUri());
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(wxAuthUrl);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 网页微信授权后跳转
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/authLogin/baseRedirect")
|
|
|
|
|
- public void wxAuthLoginRedirect(String code, String state, HttpServletResponse response) throws Exception {
|
|
|
|
|
-
|
|
|
|
|
- AuthToken token = weChatService.getAuthToken(code, wxOpenPlatYHLXLoginConfig.getAppId());
|
|
|
|
|
- //重定向
|
|
|
|
|
- baseRedirect(token, state, User.RegisterEnv.pc, response);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 网页扫描微信公众号二维码 临时凭证ticket 关注后登录
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/gzh/login/qrCode")
|
|
|
|
|
- public Result<WxGzhQrCodeTicketRep> getWxGzhQrCode(Long sharedId, Integer dsType, Long popularizeId, String dsCode) throws Exception {
|
|
|
|
|
- //获取gzh带参数的二维码
|
|
|
|
|
- WxGzhQrCodeTicketRep result = weChatService.getWxGzhQrCode(sharedId, dsType, popularizeId, null, null, dsCode);
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * pc端公众号二维码绑定微信账号信息
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/gzh/qrCode")
|
|
|
|
|
- public Result<WxGzhQrCodeTicketRep> getWxGzhBindQrcode(String loginPhone) throws Exception {
|
|
|
|
|
- WxGzhQrCodeTicketRep result = weChatService.getWxGzhQrCode(null, null, null, loginPhone, null, null);
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(result);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 根据公众号的场景值是否 已经扫码了公众号二维码
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/gzh/sceneStr/checkQrCode")
|
|
|
|
|
- public Result<String> checkQrCodeByGzhSceneStr(String sceneStr) throws Exception {
|
|
|
|
|
- String key = RedisService.key.WX_GZH_QRCODE_LOGIN.getNameFormat(sceneStr);
|
|
|
|
|
- Object value = redisService.get(key);
|
|
|
|
|
- if (value == null) {
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().setMsg("用户未扫码").toResult();
|
|
|
|
|
- }
|
|
|
|
|
- Long userId = Long.parseLong(value.toString());
|
|
|
|
|
-
|
|
|
|
|
- redisService.del(key);
|
|
|
|
|
- User user = userService.getById(userId);
|
|
|
|
|
- if (StrUtil.isEmpty(user.getRegisterEnv())) {
|
|
|
|
|
- user.setRegisterEnv(User.RegisterEnv.pc.name());
|
|
|
|
|
- userService.updateById(user);
|
|
|
|
|
- }
|
|
|
|
|
- StpUserUtil.login(userId);
|
|
|
|
|
- String token = StpUserUtil.getTokenValue();
|
|
|
|
|
- if (StrUtil.isEmpty(user.getShowId())) {
|
|
|
|
|
- user.setShowId(userService.getUserShowId(userId));
|
|
|
|
|
- }
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
|
- jsonObject.putOpt("saToken", token);
|
|
|
|
|
- jsonObject.putOpt("showId", user.getShowId());
|
|
|
|
|
- jsonObject.putOpt("nickname", user.getNickname());
|
|
|
|
|
- jsonObject.putOpt("img", user.getHeadimgurl());
|
|
|
|
|
-
|
|
|
|
|
- //发送模板消息
|
|
|
|
|
- templateCommonService.sendWxGzhQrCodeSuccessMsg(user);
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(jsonObject.toString());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * pc用户是否 已通过二维码 扫码关注公众号
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/gzh/subscribe")
|
|
|
|
|
- public Result<Boolean> isSubscribeWxGzh(String sceneStr) {
|
|
|
|
|
- String key = RedisService.key.WX_GZH_QRCODE_BIND.getNameFormat(sceneStr);
|
|
|
|
|
- Object value = redisService.get(key);
|
|
|
|
|
- if (value == null) {
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
|
|
- }
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 网页微信用户登录授权后,重定向至web端
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/wx/login/redirect")
|
|
|
|
|
- public void wxLoginRedirect(String code, String state, HttpServletResponse response) throws Exception {
|
|
|
|
|
- String domain = envCommonService.getHost();
|
|
|
|
|
- String url = String.format("%sweChat/baseRedirect?code=%s&state=%s", domain, code, state);
|
|
|
|
|
- response.sendRedirect(url);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取手机验证码
|
|
* 获取手机验证码
|
|
|
*/
|
|
*/
|
|
@@ -436,42 +184,4 @@ public class AuthorizationController {
|
|
|
UserAuthLoginResp loginPhoneRep = new UserAuthLoginResp(StpUserUtil.getTokenValue(), user.getShowId(), user.getNickname(), user.getHeadimgurl());
|
|
UserAuthLoginResp loginPhoneRep = new UserAuthLoginResp(StpUserUtil.getTokenValue(), user.getShowId(), user.getNickname(), user.getHeadimgurl());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(loginPhoneRep);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(loginPhoneRep);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public void baseRedirect(AuthToken token, String state, User.RegisterEnv registerEnv, HttpServletResponse response) throws Exception {
|
|
|
|
|
- // 根据openid 与 access_token 获取用户信息
|
|
|
|
|
- GzhOAuth2UserInfo userinfo = weChatService.getUserInfo(token.getAccessToken(), token.getOpenid());
|
|
|
|
|
-
|
|
|
|
|
- // 转跳参数
|
|
|
|
|
- String json = Codec.DoBase64.custom().setData(state).decodeAsText();
|
|
|
|
|
- AuthRedirect re = Jsons.parseObject(json, AuthRedirect.class);
|
|
|
|
|
- //保存用户信息
|
|
|
|
|
- User user = userService.saveAuth(userinfo, re.getSharedId(), re.getDsType(), re.getPid(), registerEnv, re.getDsCode(), re.getCk(), re.getCt());
|
|
|
|
|
- if (user == null) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //写回登陆信息
|
|
|
|
|
- StpUserUtil.login(user.getId());
|
|
|
|
|
- response.addHeader("satoken-user", StpUserUtil.getTokenValue());
|
|
|
|
|
-
|
|
|
|
|
- Cookie cookie = new Cookie("satoken-user", StpUserUtil.getTokenValue());
|
|
|
|
|
- cookie.setMaxAge(31536000);
|
|
|
|
|
- cookie.setPath("/");
|
|
|
|
|
- response.addCookie(cookie);
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
|
- if (StrUtil.isEmpty(user.getShowId())) {
|
|
|
|
|
- user.setShowId(userService.getUserShowId(user.getId()));
|
|
|
|
|
- }
|
|
|
|
|
- jsonObject.putOpt("showId", user.getShowId());
|
|
|
|
|
- jsonObject.putOpt("nickName", user.getNickname());
|
|
|
|
|
-
|
|
|
|
|
- Cookie userInfo = new Cookie("info", Base64.encode(jsonObject.toString()));
|
|
|
|
|
- cookie.setMaxAge(31536000);
|
|
|
|
|
- cookie.setPath("/");
|
|
|
|
|
- response.addCookie(userInfo);
|
|
|
|
|
- String url = redisService.getStr(re.getMappingId().toString());
|
|
|
|
|
- redisService.del(re.getMappingId().toString());
|
|
|
|
|
- log.info("微信授权转跳.url: {}", url);
|
|
|
|
|
- response.sendRedirect(url.contains("?") ? url + "&t=" + StpUserUtil.getTokenValue() : url + "?t=" + StpUserUtil.getTokenValue());
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|