feat(auth): 新增微信小程序登录(绑定策略:首次用学号密码绑定)

- 新增 POST /api/auth/wechat/login:用 wx.login 的 code 换 openid;已绑定直接签发 JWT 返回,未绑定返回 bindToken
- bind.post.ts:支持从请求体读取 bindToken(小程序不便维护 cookie),绑定成功后返回 token,供 Authorization: Bearer 使用
- auth-route-policy.ts:把新接口登记进免鉴权白名单,否则会被鉴权中间件拦截
- .env.example:新增 WECHAT_MINI_APPID / WECHAT_MINI_SECRET
This commit is contained in:
2026-09-26 13:57:24 +08:00
parent a140ce8621
commit 12dac95e1b
4 changed files with 178 additions and 2 deletions
+2
View File
@@ -25,6 +25,8 @@ export const PUBLIC_API_EXACT_ROUTES: readonly RoutePolicy[] = [
{ path: '/api/auth/grade-class-options', methods: GET_METHODS },
{ path: '/api/auth/oauth-register-options', methods: GET_METHODS },
{ path: '/api/auth/bind', methods: ['POST'] },
// 微信小程序登录(wx.login 的 code 换 openid);未绑定时返回 bindToken,供上面的 /api/auth/bind 使用
{ path: '/api/auth/wechat/login', methods: ['POST'] },
{ path: '/api/auth/oauth-register', methods: ['POST'] },
{ path: '/api/auth/2fa/verify', methods: ['POST'] },
{ path: '/api/auth/2fa/send-email', methods: ['POST'] },