Translate some exception message.

pull/172/head
ruibaby 2019-05-31 22:36:11 +08:00
parent 9630f9a2bb
commit c563137577
2 changed files with 5 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import run.halo.app.model.dto.UserDTO;
import run.halo.app.model.entity.User;
import run.halo.app.model.params.PasswordParam;
import run.halo.app.model.params.UserParam;
import run.halo.app.model.support.BaseResponse;
import run.halo.app.model.support.UpdateCheck;
import run.halo.app.service.UserService;
import run.halo.app.utils.ValidationUtils;
@ -45,7 +46,8 @@ public class UserController {
}
@PutMapping("profiles/password")
public void updatePassword(@RequestBody @Valid PasswordParam passwordParam, User user) {
public BaseResponse updatePassword(@RequestBody @Valid PasswordParam passwordParam, User user) {
userService.updatePassword(passwordParam.getOldPassword(), passwordParam.getNewPassword(), user.getId());
return BaseResponse.ok("密码修改成功");
}
}

View File

@ -106,7 +106,7 @@ public class UserServiceImpl extends AbstractCrudService<User, Integer> implemen
Assert.notNull(userId, "User id must not be blank");
if (oldPassword.equals(newPassword)) {
throw new BadRequestException("There is nothing changed because new password is equal to old password");
throw new BadRequestException("新密码和旧密码不能相同");
}
// Get the user
@ -114,7 +114,7 @@ public class UserServiceImpl extends AbstractCrudService<User, Integer> implemen
// Check the user old password
if (!BCrypt.checkpw(oldPassword, user.getPassword())) {
throw new BadRequestException("Old password is mismatch").setErrorData(oldPassword);
throw new BadRequestException("旧密码错误").setErrorData(oldPassword);
}
// Set new password