From 07c655745414d75d1084b315ada8526734bccedb Mon Sep 17 00:00:00 2001 From: yuzhiran Date: Mon, 15 Jun 2026 10:42:31 +0800 Subject: [PATCH] fix: return 200 instead of 201 for all login endpoints (NestJS default) --- backend/src/modules/user/user.controller.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/modules/user/user.controller.ts b/backend/src/modules/user/user.controller.ts index 089d30e..7988d27 100644 --- a/backend/src/modules/user/user.controller.ts +++ b/backend/src/modules/user/user.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Post, Get, Put, Body, Req } from '@nestjs/common' +import { Controller, Post, Get, Put, Body, Req, HttpCode, HttpStatus } from '@nestjs/common' import { UserService } from './user.service' import { Public } from '../../common/decorators/public.decorator' import { CurrentUser } from '../../common/decorators/current-user.decorator' @@ -9,12 +9,14 @@ export class UserController { @Public() @Post('send-code') + @HttpCode(HttpStatus.OK) async sendCode(@Body('phone') phone: string) { return this.userService.sendCode(phone) } @Public() @Post('login') + @HttpCode(HttpStatus.OK) async login(@Body('phone') phone: string, @Body('code') code: string) { return this.userService.loginByPhone(phone, code) } @@ -22,12 +24,14 @@ export class UserController { // 📧 邮箱验证码登录(H5 用) @Public() @Post('send-email-code') + @HttpCode(HttpStatus.OK) async sendEmailCode(@Body('email') email: string) { return this.userService.sendEmailCode(email) } @Public() @Post('email-login') + @HttpCode(HttpStatus.OK) async emailLogin(@Body('email') email: string, @Body('code') code: string) { return this.userService.loginByEmail(email, code) } @@ -35,6 +39,7 @@ export class UserController { // 密码登录 @Public() @Post('password-login') + @HttpCode(HttpStatus.OK) async passwordLogin(@Body('email') email: string, @Body('password') password: string) { return this.userService.loginByPassword(email, password) } @@ -42,6 +47,7 @@ export class UserController { // 邮箱+密码注册 @Public() @Post('register') + @HttpCode(HttpStatus.OK) async register(@Body('email') email: string, @Body('password') password: string) { return this.userService.registerWithPassword(email, password) } @@ -49,6 +55,7 @@ export class UserController { // 微信静默登录 @Public() @Post('wx-login') + @HttpCode(HttpStatus.OK) async wxLogin(@Body('code') code: string) { return this.userService.loginByWx(code) }