|
|
@@ -254,13 +254,21 @@ public class UserService {
|
|
|
/*
|
|
|
更新密码
|
|
|
*/
|
|
|
- public String setPassword(Long userId, String key, String code, String password) {
|
|
|
+ public String setPassword(String key, String code, String password,Identity identity) {
|
|
|
try {
|
|
|
smsService.verify(key, code);
|
|
|
} catch (SmsService.SmsVerifyException e) {
|
|
|
e.printStackTrace();
|
|
|
throw new BusinessException("验证码错误");
|
|
|
}
|
|
|
- return setPassword(userId, password);
|
|
|
+
|
|
|
+ User user = userRepo.findByPhoneAndIdentity(key, identity);
|
|
|
+ if (user==null){
|
|
|
+ throw new BusinessException("无用户");
|
|
|
+ }
|
|
|
+ user.setPassword(new BCryptPasswordEncoder().encode(password));
|
|
|
+ user = userRepo.save(user);
|
|
|
+ return jwtTokenUtil.generateToken(JwtUserFactory.create(user));
|
|
|
+
|
|
|
}
|
|
|
}
|