| | |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new BusinessException("验证类型不能为空"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new BusinessException("验证码不能为空"); |
| | | } |
| | | // if (StringUtils.isEmptyString(verifcode)) { |
| | | // throw new BusinessException("验证码不能为空"); |
| | | // } |
| | | |
| | | String loginPartyId = this.getLoginPartyId(); |
| | | Party party = this.partyService.cachePartyBy(loginPartyId, false); |
| | | SecUser secUser = this.secUserService.findUserByPartyId(loginPartyId); |
| | | |
| | | // 根据验证类型获取验证key verifcode_type: 1/手机;2/邮箱;3/谷歌验证器; |
| | | String key = ""; |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getPhone()) || false == party.getPhone_authority() ? "" : party.getPhone(); |
| | | errMsg = "未绑定手机号"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getEmail()) || false == party.getEmail_authority() ? "" : party.getEmail(); |
| | | errMsg = "未绑定邮箱"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(secUser.getGoogle_auth_secret()) || false == secUser.isGoogle_auth_bind() ? "" : secUser.getGoogle_auth_secret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new BusinessException(errMsg); |
| | | } |
| | | // String key = ""; |
| | | // String errMsg = ""; |
| | | // if ("1".equals(verifcode_type)) { |
| | | // key = StringUtils.isEmptyString(party.getPhone()) || false == party.getPhone_authority() ? "" : party.getPhone(); |
| | | // errMsg = "未绑定手机号"; |
| | | // } else if ("2".equals(verifcode_type)) { |
| | | // key = StringUtils.isEmptyString(party.getEmail()) || false == party.getEmail_authority() ? "" : party.getEmail(); |
| | | // errMsg = "未绑定邮箱"; |
| | | // } else if ("3".equals(verifcode_type)) { |
| | | // key = StringUtils.isEmptyString(secUser.getGoogle_auth_secret()) || false == secUser.isGoogle_auth_bind() ? "" : secUser.getGoogle_auth_secret(); |
| | | // errMsg = "未绑定谷歌验证器"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(key)) { |
| | | // throw new BusinessException(errMsg); |
| | | // } |
| | | |
| | | // 验证 |
| | | boolean passed = false; |
| | | if ("1".equals(verifcode_type) || "2".equals(verifcode_type)) { |
| | | String authcode = this.identifyingCodeTimeWindowService.getAuthCode(key); |
| | | if ((null != authcode) && (authcode.equals(verifcode))) { |
| | | passed = true; |
| | | this.identifyingCodeTimeWindowService.delAuthCode(key); |
| | | } |
| | | } else if ("3".equals(verifcode_type)) { |
| | | if (this.googleAuthService.checkCode(key, verifcode)) { |
| | | passed = true; |
| | | } |
| | | } |
| | | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRolename())) { |
| | | if (!passed) { |
| | | throw new BusinessException("验证码不正确"); |
| | | } |
| | | } |
| | | // boolean passed = false; |
| | | // if ("1".equals(verifcode_type) || "2".equals(verifcode_type)) { |
| | | // String authcode = this.identifyingCodeTimeWindowService.getAuthCode(key); |
| | | // if ((null != authcode) && (authcode.equals(verifcode))) { |
| | | // passed = true; |
| | | // this.identifyingCodeTimeWindowService.delAuthCode(key); |
| | | // } |
| | | // } else if ("3".equals(verifcode_type)) { |
| | | // if (this.googleAuthService.checkCode(key, verifcode)) { |
| | | // passed = true; |
| | | // } |
| | | // } |
| | | // |
| | | // // 如果是演示用户,则不判断验证码 |
| | | // if (!"GUEST".contentEquals(party.getRolename())) { |
| | | // if (!passed) { |
| | | // throw new BusinessException("验证码不正确"); |
| | | // } |
| | | // } |
| | | |
| | | // 更新密码 |
| | | this.partyService.updateSafeword(party, safeword); |