拆分手机号验证码验证以及密码重置

master
shijie 4 years ago
parent 73de25694e
commit b2a322ae5f
  1. 8
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java
  2. 1
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java
  3. 32
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  4. 4
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java
  5. 2
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java
  6. 2
      dq-govern-gateway/src/main/resources/jwt.properties

@ -36,7 +36,15 @@ public class UserLoginController {
return "Hello"; return "Hello";
} }
@PostMapping("/verifyMobile")
@ApiOperation(value = "验证手机号及验证码")
public ResponseResult verifyMobile(@RequestBody @Valid UserLoginRequest user){
UserLoginRequest result = userLoginService.verifyMobile(user);
return ResponseResult.SUCCESS(result);
}
@PostMapping("/getBackPwd") @PostMapping("/getBackPwd")
@ApiOperation(value = "重置密码")
public ResponseResult getBackPwd(@RequestBody @Valid UserLoginRequest user){ public ResponseResult getBackPwd(@RequestBody @Valid UserLoginRequest user){
boolean result = userLoginService.getBackPwd(user); boolean result = userLoginService.getBackPwd(user);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();

@ -12,6 +12,7 @@ import com.daqing.framework.model.response.ResponseResult;
*/ */
public interface UserLoginService extends IService<UserEntity> { public interface UserLoginService extends IService<UserEntity> {
Boolean getBackPwd(UserLoginRequest user); Boolean getBackPwd(UserLoginRequest user);
UserLoginRequest verifyMobile(UserLoginRequest user);
//登录 //登录
ResponseResult login(LoginRequest loginRequest); ResponseResult login(LoginRequest loginRequest);

@ -43,10 +43,10 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
}*/ }*/
/** /**
* 忘记密 * 验证手机号及验证
*/ */
@Override @Override
public Boolean getBackPwd(UserLoginRequest user){ public UserLoginRequest verifyMobile(UserLoginRequest user){
//判断重置密码参数是否为空 //判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getPhoneAccount())){ if(StringUtils.isEmpty(user.getPhoneAccount())){
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY);
@ -54,9 +54,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
if(StringUtils.isEmpty(user.getVerifyCode())){ if(StringUtils.isEmpty(user.getVerifyCode())){
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL);
} }
if(StringUtils.isEmpty(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY);
}
//校验手机账号是否存在 //校验手机账号是否存在
/* int count = this.count(new QueryWrapper<UserEntity>() /* int count = this.count(new QueryWrapper<UserEntity>()
.eq("phone_account", user.getPhoneAccount()));*/ .eq("phone_account", user.getPhoneAccount()));*/
@ -65,13 +63,33 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
if (count == 0) { if (count == 0) {
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST); ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST);
} }
//根据手机号查询相关信息
UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount());
//判断验证码是否匹配 //判断验证码是否匹配
String verify = "123456"; String verify = "123456";
if(!verify.equals(user.getVerifyCode())){ if(!verify.equals(user.getVerifyCode())){
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL);
} }
return user;
}
/**
* 重置密码
*/
@Override
public Boolean getBackPwd(UserLoginRequest user){
//判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY);
}
if(StringUtils.isEmpty(user.getConfirmPwd())){
ExceptionCast.cast(HrmsCode.CONFIRM_PWD_NOT_EMPTY);
}
if(!user.getConfirmPwd().equals(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT);
}
//根据手机号查询相关信息
UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount());
String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId()); String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId());
//根据手机号码修改密码 //根据手机号码修改密码

@ -30,4 +30,8 @@ public class UserLoginRequest implements Serializable {
*/ */
@Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!") @Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!")
private String newPwd; private String newPwd;
/**
* 确认密码
*/
private String confirmPwd;
} }

@ -27,6 +27,8 @@ public enum HrmsCode implements ResultCode {
NEW_PASSWORD_ILLEGAL(false,33004,"新密码格式不正确!"), NEW_PASSWORD_ILLEGAL(false,33004,"新密码格式不正确!"),
VERIFY_CODE_ILLEGAL(false,33005,"验证码不匹配!"), VERIFY_CODE_ILLEGAL(false,33005,"验证码不匹配!"),
PHNOE_ACCOUNT_NOT_EXIST(false,33006,"手机号码不存在!"), PHNOE_ACCOUNT_NOT_EXIST(false,33006,"手机号码不存在!"),
CONFIRM_PWD_NOT_EMPTY(false,33007,"确认密码不能为空!"),
TWICE_PWD_DIFFERENT(false,33008,"两次输入密码不一致!"),
EMP_POSITION_EXSIT(false, 22006, "该职位下已关联员工!"); EMP_POSITION_EXSIT(false, 22006, "该职位下已关联员工!");

@ -1 +1 @@
jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,/apiHrmsAuth/hrms/auth/userlogin/login jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,/apiHrmsAuth/hrms/auth/userlogin/login,/apiHrmsAuth/hrms/auth/userlogin/verifyMobile

Loading…
Cancel
Save