fix: 校验

This commit is contained in:
王瑜 2021-01-31 17:06:51 +08:00
parent ddb43cdf58
commit 41fb405723

View File

@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Optional;
@RestController
@ -59,7 +60,7 @@ public class UserController extends BaseController<User, UserQo> {
*/
@PutMapping("/passwords")
@Operation("修改密码")
public Result<Void> changePassword(@RequestBody UserPasswordDto passwordDto, @CurrentUser User user) {
public Result<Void> changePassword(@Valid @RequestBody UserPasswordDto passwordDto, @CurrentUser User user) {
// 检查原密码
Assert.isTrue(passwordEncoder.matches(passwordDto.getOldPassword(), user.getPassword()), "原密码不正确!");
Assert.isTrue(!passwordEncoder.matches(passwordDto.getPassword(), user.getPassword()), "新密码和旧密码一致,输入个新的吧!");