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

- 添加新的重定向 URL,包含额外参数和固定 code
- 修改 wxmpOauth2 方法,使用测试数据进行登录
This commit is contained in:
丁磊
2025-06-10 09:41:57 +08:00
parent bd70fdc498
commit 011f6c58ac

View File

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