fix: 为微信登录补充请求校验

This commit is contained in:
que01 committed 2026-09-21 11:51:38 +08:00
1 parent 41e4cc0f1c
commit 6edb9d7a30
3 files changed
+17 -3

No files matched your search

+6
View File
@@ -4,3 +4,9 @@ export class AdminLoginDto {
@IsString() username!: string;
@IsString() @MinLength(8) password!: string;
}
export class WechatLoginDto {
@IsString()
@MinLength(1)
code!: string;
}
+3 -3
View File
@@ -42,7 +42,7 @@ import {
UpdateInquiryFormDto,
} from "./admin.dto.js";
import { AdminAuthService } from "./admin-auth.service.js";
import { AdminLoginDto } from "./admin-auth.dto.js";
import { AdminLoginDto, WechatLoginDto } from "./admin-auth.dto.js";
import type { FastifyRequest } from "fastify";
import { Transform } from "class-transformer";
import type { TransformFnParams } from "class-transformer";
@@ -253,8 +253,8 @@ export class CustomerSessionController {
) {}
@Post("wechat")
async wechatLogin(@Body() body: { code?: string }): Promise<{ token: string }> {
const session = await this.wechatAuth.exchangeCode(body.code ?? "");
async wechatLogin(@Body() body: WechatLoginDto): Promise<{ token: string }> {
const session = await this.wechatAuth.exchangeCode(body.code);
const brand = await this.prisma.brandProfile.findFirst({ select: { id: true } });
if (!brand) throw new BadRequestException("品牌尚未初始化");
await this.prisma.customerUser.upsert({