fix: return 200 instead of 201 for all login endpoints (NestJS default)
This commit is contained in:
@@ -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 { UserService } from './user.service'
|
||||||
import { Public } from '../../common/decorators/public.decorator'
|
import { Public } from '../../common/decorators/public.decorator'
|
||||||
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
import { CurrentUser } from '../../common/decorators/current-user.decorator'
|
||||||
@@ -9,12 +9,14 @@ export class UserController {
|
|||||||
|
|
||||||
@Public()
|
@Public()
|
||||||
@Post('send-code')
|
@Post('send-code')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async sendCode(@Body('phone') phone: string) {
|
async sendCode(@Body('phone') phone: string) {
|
||||||
return this.userService.sendCode(phone)
|
return this.userService.sendCode(phone)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public()
|
@Public()
|
||||||
@Post('login')
|
@Post('login')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async login(@Body('phone') phone: string, @Body('code') code: string) {
|
async login(@Body('phone') phone: string, @Body('code') code: string) {
|
||||||
return this.userService.loginByPhone(phone, code)
|
return this.userService.loginByPhone(phone, code)
|
||||||
}
|
}
|
||||||
@@ -22,12 +24,14 @@ export class UserController {
|
|||||||
// 📧 邮箱验证码登录(H5 用)
|
// 📧 邮箱验证码登录(H5 用)
|
||||||
@Public()
|
@Public()
|
||||||
@Post('send-email-code')
|
@Post('send-email-code')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async sendEmailCode(@Body('email') email: string) {
|
async sendEmailCode(@Body('email') email: string) {
|
||||||
return this.userService.sendEmailCode(email)
|
return this.userService.sendEmailCode(email)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public()
|
@Public()
|
||||||
@Post('email-login')
|
@Post('email-login')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async emailLogin(@Body('email') email: string, @Body('code') code: string) {
|
async emailLogin(@Body('email') email: string, @Body('code') code: string) {
|
||||||
return this.userService.loginByEmail(email, code)
|
return this.userService.loginByEmail(email, code)
|
||||||
}
|
}
|
||||||
@@ -35,6 +39,7 @@ export class UserController {
|
|||||||
// 密码登录
|
// 密码登录
|
||||||
@Public()
|
@Public()
|
||||||
@Post('password-login')
|
@Post('password-login')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async passwordLogin(@Body('email') email: string, @Body('password') password: string) {
|
async passwordLogin(@Body('email') email: string, @Body('password') password: string) {
|
||||||
return this.userService.loginByPassword(email, password)
|
return this.userService.loginByPassword(email, password)
|
||||||
}
|
}
|
||||||
@@ -42,6 +47,7 @@ export class UserController {
|
|||||||
// 邮箱+密码注册
|
// 邮箱+密码注册
|
||||||
@Public()
|
@Public()
|
||||||
@Post('register')
|
@Post('register')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async register(@Body('email') email: string, @Body('password') password: string) {
|
async register(@Body('email') email: string, @Body('password') password: string) {
|
||||||
return this.userService.registerWithPassword(email, password)
|
return this.userService.registerWithPassword(email, password)
|
||||||
}
|
}
|
||||||
@@ -49,6 +55,7 @@ export class UserController {
|
|||||||
// 微信静默登录
|
// 微信静默登录
|
||||||
@Public()
|
@Public()
|
||||||
@Post('wx-login')
|
@Post('wx-login')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
async wxLogin(@Body('code') code: string) {
|
async wxLogin(@Body('code') code: string) {
|
||||||
return this.userService.loginByWx(code)
|
return this.userService.loginByWx(code)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user