Skip to content

Commit 3efde87

Browse files
authored
fix(server): bind phone failed (#1511)
* fix(server): fix bind phone dto * fix(server): bind phone failed
1 parent 970917d commit 3efde87

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

server/src/user/user.controller.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { ObjectId } from 'mongodb'
3232
import { EmailService } from 'src/authentication/email/email.service'
3333
import { EmailVerifyCodeType } from 'src/authentication/entities/email-verify-code'
3434
import { BindEmailDto } from './dto/bind-email.dto'
35+
import { InjectUser } from 'src/utils/decorator'
3536

3637
@ApiTags('User')
3738
@ApiBearerAuth('Authorization')
@@ -77,7 +78,7 @@ export class UserController {
7778
const user = req.user
7879
const res = await this.userService.updateAvatar(avatar, user._id)
7980

80-
return res
81+
return ResponseUtil.ok(res)
8182
}
8283

8384
/**
@@ -108,7 +109,7 @@ export class UserController {
108109
@ApiResponseObject(UserWithProfile)
109110
@UseGuards(JwtAuthGuard)
110111
@Post('bind/phone')
111-
async bindPhone(@Body() dto: BindPhoneDto, @Req() user: User) {
112+
async bindPhone(@Body() dto: BindPhoneDto, @InjectUser() user: User) {
112113
const { oldPhoneNumber, newPhoneNumber, oldSmsCode, newSmsCode } = dto
113114
// check code valid
114115
if (user.phone) {
@@ -151,7 +152,7 @@ export class UserController {
151152
const res = await this.userService.updateUser(user._id, {
152153
phone: newPhoneNumber,
153154
})
154-
return res
155+
return ResponseUtil.ok(res)
155156
}
156157

157158
/**
@@ -183,7 +184,7 @@ export class UserController {
183184
const res = await this.userService.updateUser(req.user._id, {
184185
email,
185186
})
186-
return res
187+
return ResponseUtil.ok(res)
187188
}
188189

189190
/**
@@ -213,7 +214,7 @@ export class UserController {
213214

214215
// bind username
215216
const res = await this.userService.updateUser(req.user._id, { username })
216-
return res
217+
return ResponseUtil.ok(res)
217218
}
218219

219220
/**

0 commit comments

Comments
 (0)