fix: return 200 instead of 201 for all login endpoints (NestJS default)

This commit is contained in:
yuzhiran
2026-06-15 10:42:31 +08:00
parent 18c50726cd
commit 07c6557454
+8 -1
View File
@@ -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)
}