|
@ -2,12 +2,15 @@ package com.epmet.controller; |
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
|
|
import com.epmet.commons.tools.utils.RSASignature; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.dto.form.StaffResetPassWordFormDTO; |
|
|
import com.epmet.dto.form.StaffResetPassWordFormDTO; |
|
|
import com.epmet.dto.result.MineResultDTO; |
|
|
import com.epmet.dto.result.MineResultDTO; |
|
|
import com.epmet.service.MineService; |
|
|
import com.epmet.service.MineService; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
@ -21,6 +24,8 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("mine") |
|
|
@RequestMapping("mine") |
|
|
public class MineController { |
|
|
public class MineController { |
|
|
|
|
|
@Value("${epmet.login.privateKey}") |
|
|
|
|
|
private String privateKey; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private MineService mineService; |
|
|
private MineService mineService; |
|
|
|
|
|
|
|
@ -45,9 +50,20 @@ public class MineController { |
|
|
* @Date 2020/7/1 9:59 |
|
|
* @Date 2020/7/1 9:59 |
|
|
**/ |
|
|
**/ |
|
|
@PostMapping("resetpassword") |
|
|
@PostMapping("resetpassword") |
|
|
public Result resetPassword(@LoginUser TokenDto tokenDto, @RequestBody StaffResetPassWordFormDTO formDTO) { |
|
|
public Result resetPassword(@LoginUser TokenDto tokenDto, @RequestBody StaffResetPassWordFormDTO formDTO) throws Exception { |
|
|
formDTO.setStaffId(tokenDto.getUserId()); |
|
|
formDTO.setStaffId(tokenDto.getUserId()); |
|
|
ValidatorUtils.validateEntity(formDTO, StaffResetPassWordFormDTO.AddUserShowGroup.class, StaffResetPassWordFormDTO.AddUserInternalGroup.class); |
|
|
ValidatorUtils.validateEntity(formDTO, StaffResetPassWordFormDTO.AddUserShowGroup.class, StaffResetPassWordFormDTO.AddUserInternalGroup.class); |
|
|
|
|
|
//解密密码
|
|
|
|
|
|
if (formDTO.getConfirmNewPassword().length() > 50) { |
|
|
|
|
|
String confirmNewPassWord = RSASignature.decryptByPrivateKey(formDTO.getConfirmNewPassword(), privateKey); |
|
|
|
|
|
String newPassword = RSASignature.decryptByPrivateKey(formDTO.getNewPassword(), privateKey); |
|
|
|
|
|
formDTO.setConfirmNewPassword(confirmNewPassWord); |
|
|
|
|
|
formDTO.setNewPassword(newPassword); |
|
|
|
|
|
if (StringUtils.isNotBlank(formDTO.getOldPassword())){ |
|
|
|
|
|
String oldPassWord = RSASignature.decryptByPrivateKey(formDTO.getOldPassword(), privateKey); |
|
|
|
|
|
formDTO.setOldPassword(oldPassWord); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return mineService.resetPassword(formDTO); |
|
|
return mineService.resetPassword(formDTO); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|