refactor(login): 调整微信公众号 OAuth2 登录流程- 注释掉原有的授权 URL生成和重定向逻辑

- 新增测试用 TokenBean 对象,用于模拟登录成功后的处理
- 修改重定向 URL,增加测试参数
This commit is contained in:
丁磊
2025-06-10 10:08:44 +08:00
parent 82c8076724
commit 7b7aee2495

View File

@@ -170,8 +170,9 @@ public class LoginController {
extra = "";
}
String configUrl = globalConfig.buildPath("/login/wxmp/oauth2/" + service + "?extra=" + extra);
String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_base");
response.sendRedirect(authorizationUrl);
// String authorizationUrl = platformWxmpConfig.buildAuthorizationUrl(service, configUrl, "snsapi_base");
// response.sendRedirect(authorizationUrl);
response.sendRedirect(configUrl+"&to=mobile&code=200");
}
@@ -181,9 +182,13 @@ public class LoginController {
@RequestMapping("/wxmp/oauth2/{service}")
@OperationIgnore
public void wxmpOauth2(@PathVariable String service, CodeExtraDTO dto, HttpServletResponse response) {
WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo(wxUserInfo.getAppId(),
wxUserInfo.getOpenid(), "wxmp", JSON.toJSONString(wxUserInfo)));
// WxUserInfo wxUserInfo = platformWxmpConfig.getOAuth2AccessToken(service, dto.getCode());
// TokenBean tokenBean = corePlatformUniqueService.login(new DoLoginInfo(wxUserInfo.getAppId(),
// wxUserInfo.getOpenid(), "wxmp", JSON.toJSONString(wxUserInfo)));
TokenBean tokenBean = new TokenBean();
tokenBean.setId("testid");
tokenBean.setRoleId("testroleid");
tokenBean.setExtra("testextra");
corePlatformUniqueService.redirect(tokenBean, dto.getTo(), dto.getExtra(), response);
}