|
@@ -6,6 +6,7 @@ import com.yonge.cooleshow.auth.api.dto.UpdatePasswordDto;
|
|
|
import com.yonge.cooleshow.auth.api.dto.UserSetReq;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysRole;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.UserPassword;
|
|
|
import com.yonge.cooleshow.auth.api.vo.UserSetVo;
|
|
|
import com.yonge.cooleshow.auth.core.service.CustomTokenServices;
|
|
|
import com.yonge.cooleshow.auth.service.SysConfigService;
|
|
@@ -40,6 +41,7 @@ import org.springframework.http.MediaType;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
@@ -672,4 +674,28 @@ public class UserController extends BaseController {
|
|
|
result.put("customerServicePhone",sysConfigService.findConfigValue("customer_service_phone"));
|
|
|
return succeed(result);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/checkPassword")
|
|
|
+ @ApiOperation(value = "校验密码")
|
|
|
+ public Object checkPassword(@Validated @RequestBody UserPassword.CheckPassword checkPassword){
|
|
|
+ AuthUser authUser = SecurityUtils.getUser();
|
|
|
+ SysUser sysUser = sysUserService.get(authUser.getUserId());
|
|
|
+ BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
|
|
+ if(!encoder.matches(checkPassword.getPassword(),sysUser.getPassword())){
|
|
|
+ throw new BizException("原密码错误");
|
|
|
+ }
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/checkVerityCode")
|
|
|
+ @ApiOperation(value = "校验验证码")
|
|
|
+ public Object checkVerityCode(@Validated @RequestBody UserPassword.CheckVerityCode checkVerityCode) {
|
|
|
+ AuthUser authUser = SecurityUtils.getUser();
|
|
|
+ SysUser sysUser = sysUserService.get(authUser.getUserId());
|
|
|
+ if (!smsCodeService.verifyValidCode(sysUser.getPhone(), checkVerityCode.getCode(),
|
|
|
+ "SMS_VERIFY_CODE_UPDATE_PSW")) {
|
|
|
+ return failed("验证码错误");
|
|
|
+ }
|
|
|
+ return succeed();
|
|
|
+ }
|
|
|
}
|