|
@@ -100,22 +100,12 @@ public class CpsBackLoginController {
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/wx/authLogin")
|
|
@GetMapping("/wx/authLogin")
|
|
|
public Result<CpsAuthDto> wxAuthorize(String redirectUrl) throws Exception {
|
|
public Result<CpsAuthDto> wxAuthorize(String redirectUrl) throws Exception {
|
|
|
- Object authUrlObj = redisService.get(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("cps", wxOpenPlatYHLXLoginConfig.getAppId()));
|
|
|
|
|
- if (authUrlObj != null) {
|
|
|
|
|
- CpsAuthDto cpsAuthDto = Jsons.parseObject(authUrlObj.toString(), CpsAuthDto.class);
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
|
|
|
|
|
- }
|
|
|
|
|
CpsAuthDto cpsAuthDto = new CpsAuthDto();
|
|
CpsAuthDto cpsAuthDto = new CpsAuthDto();
|
|
|
- Long mappingId = SEQUENCE.nextId();
|
|
|
|
|
- String authState = mappingId.toString();
|
|
|
|
|
- redisService.set(authState, authState, 60 * 60 * 24L);
|
|
|
|
|
- AuthRedirect redirect = new AuthRedirect().setMappingId(mappingId);
|
|
|
|
|
|
|
+ AuthRedirect redirect = new AuthRedirect();
|
|
|
redirect.setUrl(redirectUrl);
|
|
redirect.setUrl(redirectUrl);
|
|
|
String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
String state = Codec.DoBase64.custom().setData(Jsons.toJson(redirect)).encodeAsText();
|
|
|
String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), wxOpenPlatYHLXLoginConfig.getCpsRedirectUri());
|
|
String wxAuthUrl = authorizationService.createWxAuthLoginUrl(state, wxOpenPlatYHLXLoginConfig.getAppId(), wxOpenPlatYHLXLoginConfig.getCpsRedirectUri());
|
|
|
cpsAuthDto.setAuthUrl(wxAuthUrl);
|
|
cpsAuthDto.setAuthUrl(wxAuthUrl);
|
|
|
- cpsAuthDto.setAuthState(authState);
|
|
|
|
|
- redisService.set(RedisService.key.WX_LOGIN_AUTH_URI.getNameFormat("cps", wxOpenPlatYHLXLoginConfig.getAppId()), Jsons.toJson(cpsAuthDto), RedisService.key.WX_LOGIN_AUTH_URI.getTimeout());
|
|
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(cpsAuthDto);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -143,17 +133,8 @@ public class CpsBackLoginController {
|
|
|
if (userDistribute == null) throw BusinessRuntimeException.getInstance("只支持渠道分销用户登录");
|
|
if (userDistribute == null) throw BusinessRuntimeException.getInstance("只支持渠道分销用户登录");
|
|
|
StpCpsManageUser.login(user.getId());
|
|
StpCpsManageUser.login(user.getId());
|
|
|
String cpsToken = StpCpsManageUser.getTokenValue();
|
|
String cpsToken = StpCpsManageUser.getTokenValue();
|
|
|
- String url = re.getUrl();
|
|
|
|
|
- if (StrUtil.isNotBlank(url)) {
|
|
|
|
|
- response.sendRedirect(url.contains("?") ? url + "&t=" + cpsToken : url + "?t=" + cpsToken);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- JSONObject res = new JSONObject();
|
|
|
|
|
- res.putOpt("satoken-cpsUser", cpsToken);
|
|
|
|
|
- res.putOpt("img", user.getHeadimgurl());
|
|
|
|
|
- res.putOpt("nickname", user.getNickname());
|
|
|
|
|
- redisService.set(RedisService.key.CPS_AUTH_SUCCESS_KEY.getNameFormat(re.getMappingId()), res.toString(), RedisService.key.CPS_BACK_LOGIN_KEY.getTimeout());
|
|
|
|
|
- response.sendRedirect(wxOpenPlatYHLXLoginConfig.getCpsLoginUrl());
|
|
|
|
|
|
|
+ String url = Optional.ofNullable(re.getUrl()).orElse(wxOpenPlatYHLXLoginConfig.getLoginUrl());
|
|
|
|
|
+ response.sendRedirect(url.contains("?") ? url + "&t=" + cpsToken : url + "?t=" + cpsToken);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|