feat: 小程序获取手机号支持openid校验 - #4078
Conversation
🤖 Augment PR SummarySummary: 本 PR 为小程序用户服务的“手机号快速验证”接口增加了可选的
GET_PHONE_NUMBER_URL 端点与 JSON 请求体,新增字段仅在传入 openid 时发送。
🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
本 PR 针对小程序“获取手机号”接口补齐微信服务端可选的 openid 参数传递能力,使调用方能够触发微信服务端对 openid 与 code 绑定关系的校验,从而满足防越权校验需求(关联 #4076)。
Changes:
- 在
WxMaUserService新增getPhoneNumber(String code, String openid)重载方法声明。 - 在
WxMaUserServiceImpl中实现重载方法:请求体在openid非空时追加openid字段;原单参方法委托到新方法以保持行为一致。 - 新增单元测试
WxMaUserServiceImplPhoneNumberTest,验证请求体包含code+openid。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java | 新增获取手机号接口的 openid 重载声明(建议用 default 方法避免对外实现的二进制不兼容)。 |
| weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java | 构造请求 JSON 时可选加入 openid,并保持原方法兼容。 |
| weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplPhoneNumberTest.java | 新增测试验证请求体包含 openid(当前存在 unused import 导致编译失败,需修复)。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 701070b954
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
概述
为
WxMaUserService#getPhoneNumber增加可选openid参数,使调用方可请求微信服务端校验openid与手机号获取凭证code的绑定关系。变更
getPhoneNumber(String code, String openid)重载。code和openid。验证
java -cp "weixin-java-miniapp/target/test-classes:weixin-java-miniapp/target/classes:$(< /tmp/wxjava-miniapp-test-classpath)" org.testng.TestNG -testclass cn.binarywang.wx.miniapp.api.impl.WxMaUserServiceImplPhoneNumberTestFixes #4076