微信SDK接通

This commit is contained in:
2026-07-01 19:56:44 +08:00
parent a1cbfc7241
commit aea1513836
38 changed files with 1610 additions and 92 deletions
@@ -3,8 +3,10 @@ import type { Request } from 'express';
import { AuthService } from './auth.service';
import {
BindPhoneDto,
BindWechatPhoneDto,
BootstrapSessionDto,
LoginSmsDto,
LoginWechatDto,
RefreshTokenDto,
SendSmsDto,
} from './dto/auth.dto';
@@ -48,13 +50,26 @@ export class UserAuthController {
}
@Post('auth/login/wechat')
wechatLogin() {
return this.authService.wechatDisabled();
@UseGuards(OptionalJwtAuthGuard)
wechatLogin(@Req() req: Request, @Body() dto: LoginWechatDto) {
const guest = (req as Request & { user?: AuthUser }).user;
const guestId = guest?.actorType === 'USER' ? guest.actorId : undefined;
return this.authService.loginUserWechat(
dto.code,
ClientApp.USER_H5,
dto.platform ?? 'h5',
guestId,
);
}
@Post('auth/wechat/bind-phone')
bindPhoneLegacy() {
return this.authService.wechatDisabled();
bindPhoneLegacy(@Body() dto: BindWechatPhoneDto) {
return this.authService.bindWechatPhone(
dto.wxSessionKey,
dto.phone,
dto.code,
ClientApp.USER_H5,
);
}
@Get('auth/me')
@@ -79,8 +94,8 @@ export class ShopAuthController {
}
@Post('login/wechat')
wechatLogin() {
return this.authService.wechatDisabled();
wechatLogin(@Body() dto: LoginWechatDto) {
return this.authService.loginStoreWechat(dto.code, ClientApp.SHOP_H5, dto.platform ?? 'h5');
}
}
@@ -99,8 +114,8 @@ export class PartnerAuthController {
}
@Post('login/wechat')
wechatLogin() {
return this.authService.wechatDisabled();
wechatLogin(@Body() dto: LoginWechatDto) {
return this.authService.loginPartnerWechat(dto.code, ClientApp.PARTNER_H5, dto.platform ?? 'h5');
}
}