update forgetPassword route url
This commit is contained in:
parent
03ad1187ce
commit
56ae208717
@ -5,4 +5,7 @@ export class ResetPassword extends EmailVerifyDto {
|
||||
@IsNotEmpty()
|
||||
@IsStrongPassword()
|
||||
password: string
|
||||
|
||||
@IsNotEmpty()
|
||||
userId: string
|
||||
}
|
||||
|
@ -23,12 +23,9 @@ export class UsersController {
|
||||
return this.usersService.loginByEmail(user.email, user.password)
|
||||
}
|
||||
|
||||
@Patch(':id/password')
|
||||
@Patch('password')
|
||||
@ApiOperation({ summary: '找回密码' })
|
||||
async forgetPassword(
|
||||
@Body() payload: ResetPassword,
|
||||
@Param('id') userId: string,
|
||||
) {
|
||||
return this.usersService.resetPasswordByEmail(payload, userId)
|
||||
async forgetPassword(@Body() payload: ResetPassword) {
|
||||
return this.usersService.resetPasswordByEmail(payload)
|
||||
}
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ export class UsersService {
|
||||
}
|
||||
|
||||
@VerifyEmail(EmailScene.forgetPassword)
|
||||
async resetPasswordByEmail(data: ResetPassword, userId: string) {
|
||||
async resetPasswordByEmail(data: ResetPassword) {
|
||||
const { password } = data
|
||||
const hashedPassword = await bcrypt.hash(
|
||||
password,
|
||||
this.secureConfig.bcryptSaltOrRound,
|
||||
)
|
||||
const user = await this.prismaService.user.update({
|
||||
where: { id: userId },
|
||||
where: { id: data.userId },
|
||||
data: { password: hashedPassword },
|
||||
})
|
||||
return this.generateTokens({ userId: user.id })
|
||||
|
Loading…
Reference in New Issue
Block a user