Commit 3e0c8343 authored by renjie's avatar renjie

重置密码

parent dab1fa7a
...@@ -202,7 +202,7 @@ public class AccountController { ...@@ -202,7 +202,7 @@ public class AccountController {
accountService.updateUserToken(username, token); accountService.updateUserToken(username, token);
} }
@RequestMapping(path = "/reset", method = RequestMethod.POST) @RequestMapping(path = "/resetpassword", method = RequestMethod.POST)
public ResultDto forgetPassword(@Valid @RequestBody UserDto user) { public ResultDto forgetPassword(@Valid @RequestBody UserDto user) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
...@@ -223,7 +223,7 @@ public class AccountController { ...@@ -223,7 +223,7 @@ public class AccountController {
return accountService.determUsernameOrEmail(text); return accountService.determUsernameOrEmail(text);
} }
@RequestMapping(path = "/resetwithotp", method = RequestMethod.POST) @RequestMapping(path = "/reset", method = RequestMethod.POST)
public ResultDto resetWithOtp(@Valid @RequestBody UserDto user) { public ResultDto resetWithOtp(@Valid @RequestBody UserDto user) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
......
...@@ -782,7 +782,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -782,7 +782,7 @@ public class AccountServiceImpl implements AccountService {
@Override @Override
public void resetPasswordWithOtp(UserDto user) { public void resetPasswordWithOtp(UserDto user) {
Otp otp = otpRepository.findByPhoneAndCreatedAtGreaterThanEqual(user.getPhone(), Otp otp = otpRepository.findByPhoneAndCreatedAtGreaterThanEqual(user.getUsername(),
Instant.now().minusSeconds(600).toEpochMilli()); Instant.now().minusSeconds(600).toEpochMilli());
if (otp == null) { if (otp == null) {
throw new ClientRequestException(AccountErrorCode.OTPWRONG, AccountErrorCode.OTPWRONG.getReason()); throw new ClientRequestException(AccountErrorCode.OTPWRONG, AccountErrorCode.OTPWRONG.getReason());
...@@ -791,7 +791,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -791,7 +791,7 @@ public class AccountServiceImpl implements AccountService {
throw new ClientRequestException(AccountErrorCode.OTPWRONG, AccountErrorCode.OTPWRONG.getReason()); throw new ClientRequestException(AccountErrorCode.OTPWRONG, AccountErrorCode.OTPWRONG.getReason());
} }
Account account = repository.findByPhoneNumber(user.getPhone()); Account account = repository.findById(user.getUsername()).orElse(null);
if (account == null) if (account == null)
throw new ClientRequestException(AccountErrorCode.PHONENOTEXIST, "Can't find account with phone " + user.getPhone()); throw new ClientRequestException(AccountErrorCode.PHONENOTEXIST, "Can't find account with phone " + user.getPhone());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment