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