| | |
| | | public Result login(String username, String password) { |
| | | |
| | | if (StringUtils.isEmptyString(username)) { |
| | | throw new YamiShopBindException("用户名不能为空"); |
| | | throw new YamiShopBindException("Username cannot be empty"); |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new YamiShopBindException("登录密码不能为空"); |
| | | throw new YamiShopBindException("The login password cannot be empty"); |
| | | } |
| | | if (password.length() < 6 || password.length() > 12) { |
| | | throw new YamiShopBindException("登录密码必须6-12位"); |
| | | throw new YamiShopBindException("The login password must be 6 to 12 characters long."); |
| | | } |
| | | String ip = IPHelper.getIpAddr(); |
| | | if (!IpUtil.isCorrectIpRegular(ip)) { |
| | | log.error("校验IP不合法,参数{}", ip); |
| | | throw new YamiShopBindException("校验IP不合法"); |
| | | throw new YamiShopBindException("Invalid IP address"); |
| | | } |
| | | |
| | | // 黑名单限制 |
| | |
| | | String[] ips = blackUsers.split(","); |
| | | |
| | | if(Arrays.asList(ips).contains(ip.trim())){ |
| | | throw new YamiShopBindException("当前用户在黑名单中"); |
| | | throw new YamiShopBindException("The current user is on the blacklist."); |
| | | } |
| | | } |
| | | |
| | |
| | | private String validateParam(String username, String verifcode, String password, String type) { |
| | | |
| | | if (StringUtils.isEmptyString(username)) { |
| | | return "用户名不能为空"; |
| | | return "Username cannot be empty"; |
| | | } |
| | | // if (StringUtils.isEmptyString(verifcode)) { |
| | | // return "验证码不能为空"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(verifcode)) { |
| | | // return "Verification code cannot be empty"; |
| | | // } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | return "登录密码不能为空"; |
| | | return "Login password cannot be empty"; |
| | | } |
| | | int min = 6; |
| | | int max = 12; |
| | | if (!RegexUtil.length(password, min, max)) { |
| | | return "登陆密码长度不符合设定"; |
| | | return "Login password length does not meet the requirements"; |
| | | } |
| | | // if (!RegexUtil.isDigits(this.password)) { |
| | | // // 只能输入数字 |
| | | // return "登陆密码不符合设定"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(this.usercode)) { |
| | | // return "推荐码不能为空"; |
| | | // } |
| | | // if (!RegexUtil.isDigits(this.password)) { |
| | | // // Only digits allowed |
| | | // return "Login password does not meet the requirements"; |
| | | // } |
| | | // if (StringUtils.isEmptyString(this.usercode)) { |
| | | // return "Referral code cannot be empty"; |
| | | // } |
| | | if (StringUtils.isEmptyString(type) || !Arrays.asList("1", "2").contains(type)) { |
| | | return "类型不能为空"; |
| | | return "Type cannot be empty"; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | if (!StringUtils.isNullOrEmpty(error)) { |
| | | throw new YamiShopBindException(error); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | /*if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | } |
| | | throw new YamiShopBindException("Fund password does not meet requirements"); |
| | | }*/ |
| | | //默认123456 |
| | | safeword = "123456"; |
| | | userService.saveRegister(username, password, usercode, safeword, verifcode, type); |
| | | User secUser = userService.findByUserName(username); |
| | | Log log = new Log(); |
| | | log.setCategory(Constants.LOG_CATEGORY_SECURITY); |
| | | log.setLog("用户注册,ip[" + IPHelper.getIpAddr() + "]"); |
| | | log.setUserId(secUser.getUserId()); |
| | | log.setUsername(username); |
| | | logService.save(log); |
| | | UserInfoInTokenBO userInfoInToken = new UserInfoInTokenBO(); |
| | | userInfoInToken.setUserId(secUser.getUserId()); |
| | | userInfoInToken.setSysType(SysTypeEnum.ORDINARY.value()); |
| | | userInfoInToken.setEnabled(secUser.getStatus() == 1); |
| | | tokenStore.deleteAllToken(String.valueOf(SysTypeEnum.ORDINARY.value()), String.valueOf(secUser.getUserId())); |
| | | TokenInfoVO tokenInfoVO = tokenStore.storeAndGetVo(userInfoInToken); |
| | | this.userService.online(secUser.getUserId()); |
| | | this.ipMenuService.saveIpMenuWhite(IPHelper.getIpAddr()); |
| | | Map<String, Object> data = new HashMap<String, Object>(); |
| | | data.put("token", tokenInfoVO.getAccessToken()); |
| | | data.put("username", secUser.getUserName()); |
| | | data.put("usercode", secUser.getUserName()); |
| | | secUser.setUserLastip(IPHelper.getIpAddr()); |
| | | userService.updateById(secUser); |
| | | return Result.succeed(data); |
| | | } |
| | | |
| | | /** |
| | | * 重置登录账号 |
| | | */ |
| | | @RequestMapping("resetUserName") |
| | | public Object resetUserName(String username, String password, String safeword, String verifcode, String type) { |
| | | String userId = SecurityUtils.getUser().getUserId(); |
| | | if (StringUtils.isEmptyString(userId)) { |
| | | throw new YamiShopBindException("Please log in first"); |
| | | } |
| | | // 重置类型:1/手机;2/邮箱; |
| | | String error = this.validateParam(username, verifcode, password, type); |
| | | if (!StringUtils.isNullOrEmpty(error)) { |
| | | throw new YamiShopBindException(error); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | userService.resetUserName(userId ,username, password, safeword, verifcode, type); |
| | | |
| | | User secUser = userService.findByUserName(username); |
| | | Log log = new Log(); |
| | | log.setCategory(Constants.LOG_CATEGORY_SECURITY); |
| | | log.setLog("用户重置登录账号,ip[" + IPHelper.getIpAddr() + "]"); |
| | | log.setUserId(secUser.getUserId()); |
| | | log.setUsername(username); |
| | | logService.save(log); |
| | |
| | | throw new YamiShopBindException("The fund password cannot be blank"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("The fund password does not match the settings."); |
| | | } |
| | | userService.setSafeword(SecurityUtils.getUser().getUserId(), passwordEncoder.encode(model.getSafeword())); |
| | | return Result.succeed(null); |
| | |
| | | String verifcode_type = request.getParameter("verifcode_type"); |
| | | String verifcode = request.getParameter("verifcode"); |
| | | if (StringUtils.isEmptyString(username)) { |
| | | throw new YamiShopBindException("用户名不能为空"); |
| | | throw new YamiShopBindException("Username is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new YamiShopBindException("密码不能为空"); |
| | | throw new YamiShopBindException("Password is required"); |
| | | } |
| | | if (password.length() < 6 || password.length() > 12) { |
| | | throw new YamiShopBindException("密码必须6-12位"); |
| | | throw new YamiShopBindException("Password must be 6-12 characters"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new YamiShopBindException("验证类型不能为空"); |
| | | throw new YamiShopBindException("Verification type is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("验证码不能为空"); |
| | | throw new YamiShopBindException("Verification code is required"); |
| | | } |
| | | User party = userService.findByUserName(username); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("用户名不存在"); |
| | | throw new YamiShopBindException("Username does not exist"); |
| | | } |
| | | // 根据验证类型获取验证key verifcode_type: 1/手机;2/邮箱;3/谷歌验证器; |
| | | String key = ""; |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMobile()) || false == party.isUserMobileBind() ? "" : party.getUserMobile(); |
| | | errMsg = "未绑定手机号"; |
| | | errMsg = "Phone number is not bound"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMail()) || false == party.isMailBind() ? "" : party.getUserMail(); |
| | | errMsg = "未绑定邮箱"; |
| | | errMsg = "Email is not bound"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getGoogleAuthSecret()) || false == party.isGoogleAuthBind() ? "" : party.getGoogleAuthSecret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | errMsg = "Google Authenticator is not bound"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new YamiShopBindException(errMsg); |
| | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if (!passed) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | party.setLoginPassword(passwordEncoder.encode(password)); |
| | |
| | | |
| | | Map<String, Object> data = new HashMap<>(); |
| | | if (StringUtils.isEmptyString(username)) { |
| | | throw new YamiShopBindException("用户名参数为空"); |
| | | throw new YamiShopBindException("Username is required"); |
| | | } |
| | | User party = userService.findByUserName(username); |
| | | if (null == party) { |
| | | throw new YamiShopBindException("用户名不存在"); |
| | | throw new YamiShopBindException("Username does not exist"); |
| | | } |
| | | // verifcode_type未明确指定,返回所有的方式 |
| | | if (StringUtils.isEmptyString(verifcode_type) || !Arrays.asList("1", "2", "3").contains(verifcode_type)) { |
| | |
| | | map.put("user_level_custom", (int) Math.floor(party.getUserLevel() / 10)); |
| | | String projectType = this.sysparaService.find("project_type").getSvalue(); |
| | | if (StringUtils.isEmptyString(projectType)) { |
| | | throw new BusinessException("系统参数错误"); |
| | | throw new BusinessException("System parameter error"); |
| | | } |
| | | if (projectType.equals("DAPP_EXCHANGE_BINANCE") |
| | | || projectType.equals("EXCHANGE_EASYCRYPTO") |
| | |
| | | } |
| | | } |
| | | } |
| | | map.put("partyId", party.getUserId()); |
| | | map.put("username", party.getUserName()); |
| | | map.put("userrole", party.getRoleName()); |
| | | map.put("usercode", party.getUserCode()); |
| | |
| | | map.put("advancedverif", party.isHighlevelAuthority()); |
| | | map.put("lastlogintime", party.getUserLasttime()); |
| | | map.put("lastloginip", party.getUserLastip()); |
| | | map.put("creditScore", party.getCreditScore()); |
| | | // 实名认证通过返回真实姓名 |
| | | if (party.isRealNameAuthority()) { |
| | | if (party.isRealNameAuthority() && kyc != null) { |
| | | map.put("name", kyc.getName()); |
| | | } |
| | | if (null != kyc) { |
| | |
| | | String usercode) { |
| | | // if (StringUtils.isEmptyString(phone) || !Strings.isNumber(phone) || phone.length() > 15) { |
| | | if (StringUtils.isEmptyString(phone) || phone.length() > 20) { |
| | | throw new YamiShopBindException("请填写正确的电话号码"); |
| | | throw new YamiShopBindException("Please enter a valid phone number"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getUser().getUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | | if (null != party.getUserMobile() && party.getUserMobile().equals(phone) && true == party.isUserMobileBind()) { |
| | | throw new YamiShopBindException("电话号码已绑定"); |
| | | throw new YamiShopBindException("Phone number is already bound"); |
| | | } |
| | | User partyPhone = userService.findPartyByVerifiedPhone(phone); |
| | | if (null != partyPhone && !partyPhone.getUserId().toString().equals(loginPartyId)) { |
| | | throw new YamiShopBindException("电话号码已绑定其他用户"); |
| | | throw new YamiShopBindException("Phone number is bound to another user"); |
| | | } |
| | | String authcode = identifyingCodeTimeWindowService.getAuthCode(phone); |
| | | String bind_phone_email_ver = this.sysparaService.find("bind_phone_email_ver").getSvalue(); |
| | |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if ("1".contentEquals(bind_phone_email_ver)) { |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("请填写正确的验证码"); |
| | | throw new YamiShopBindException("Please enter a valid verification code"); |
| | | } |
| | | if ((null == authcode) || (!authcode.equals(verifcode))) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | if ("1".contentEquals(bind_usercode)) { |
| | | if (StringUtils.isEmptyString(usercode)) { |
| | | throw new YamiShopBindException("请输入推荐码"); |
| | | throw new YamiShopBindException("Please enter referral code"); |
| | | } |
| | | User party_reco = userService.findUserByUserCode(usercode); |
| | | if (null == party_reco || party_reco.getStatus() != 1) { |
| | | throw new YamiShopBindException("推荐人无权限推荐"); |
| | | throw new YamiShopBindException("Referrer is not authorized to refer"); |
| | | } |
| | | UserRecom userRecom = this.userRecomService.findByPartyId(party.getUserId()); |
| | | if (null == userRecom) { |
| | |
| | | public Result<?> save_email(String email, String verifcode) { |
| | | |
| | | if (StringUtils.isEmptyString(email) || !Strings.isEmail(email)) { |
| | | throw new YamiShopBindException("请填写正确的邮箱地址"); |
| | | throw new YamiShopBindException("Please enter a valid email address"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getUser().getUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | | if (null != party.getUserMail() && party.getUserMail().equals(email) && true == party.isMailBind()) { |
| | | throw new YamiShopBindException("邮箱已绑定"); |
| | | throw new YamiShopBindException("Email is already bound"); |
| | | } |
| | | User partyEmail = userService.findPartyByVerifiedEmail(email); |
| | | if (null != partyEmail && !partyEmail.getUserId().toString().equals(loginPartyId)) { |
| | | throw new YamiShopBindException("邮箱已绑定其他用户"); |
| | | throw new YamiShopBindException("Email is bound to another user"); |
| | | } |
| | | String authcode = this.identifyingCodeTimeWindowService.getAuthCode(email); |
| | | String bind_phone_email_ver = sysparaService.find("bind_phone_email_ver").getSvalue(); |
| | |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if ("1".contentEquals(bind_phone_email_ver)) { |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("请填写正确的验证码"); |
| | | throw new YamiShopBindException("Please enter a valid verification code"); |
| | | } |
| | | if ((null == authcode) || (!authcode.equals(verifcode))) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | } |
| | |
| | | String verifcode_type = request.getParameter("verifcode_type"); |
| | | String verifcode = request.getParameter("verifcode"); |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new BusinessException("密码不能为空"); |
| | | throw new BusinessException("Password is required"); |
| | | } |
| | | if (password.length() < 6 || password.length() > 12) { |
| | | throw new BusinessException("密码必须6-12位"); |
| | | throw new BusinessException("Password must be 6-12 characters"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new BusinessException("验证类型不能为空"); |
| | | throw new BusinessException("Verification type is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new BusinessException("验证码不能为空"); |
| | | throw new BusinessException("Verification code is required"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getCurrentUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMobile()) || false == party.isUserMobileBind() ? "" : party.getUserMobile(); |
| | | errMsg = "未绑定手机号"; |
| | | errMsg = "Phone number is not bound"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMail()) || false == party.isMailBind() ? "" : party.getUserMail(); |
| | | errMsg = "未绑定邮箱"; |
| | | errMsg = "Email is not bound"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getGoogleAuthSecret()) || false == party.isGoogleAuthBind() ? "" : party.getGoogleAuthSecret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | errMsg = "Google Authenticator is not bound"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new BusinessException(errMsg); |
| | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if (!passed) { |
| | | throw new BusinessException("验证码不正确"); |
| | | throw new BusinessException("Incorrect verification code"); |
| | | } |
| | | } |
| | | party.setLoginPassword(passwordEncoder.encode(password)); |
| | |
| | | public Result updateOldAndNewPsw(String old_password, String password, String re_password) { |
| | | |
| | | if (StringUtils.isEmptyString(old_password)) { |
| | | throw new YamiShopBindException("旧密码不能为空"); |
| | | throw new YamiShopBindException("Old password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(password)) { |
| | | throw new YamiShopBindException("新密码不能为空"); |
| | | throw new YamiShopBindException("New password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(re_password)) { |
| | | throw new YamiShopBindException("新密码确认不能为空"); |
| | | throw new YamiShopBindException("Password confirmation is required"); |
| | | } |
| | | if (old_password.length() < 6 || old_password.length() > 12 || password.length() < 6 || password.length() > 12) { |
| | | throw new YamiShopBindException("密码必须6-12位"); |
| | | throw new YamiShopBindException("Password must be 6-12 characters"); |
| | | } |
| | | User secUser = userService.getById(SecurityUtils.getUser().getUserId()); |
| | | if (!passwordEncoder.matches(old_password, secUser.getLoginPassword())) { |
| | | throw new YamiShopBindException("旧密码不正确!"); |
| | | throw new YamiShopBindException("Incorrect old password"); |
| | | } |
| | | if (!password.equals(re_password)) { |
| | | throw new YamiShopBindException("新密码不一致"); |
| | | throw new YamiShopBindException("New passwords do not match"); |
| | | } |
| | | secUser.setLoginPassword(passwordEncoder.encode(re_password)); |
| | | userService.updateById(secUser); |
| | |
| | | public Result setSafeword(String safeword, String verifcode_type, String verifcode) { |
| | | |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("Fund password does not meet requirements"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode_type)) { |
| | | throw new YamiShopBindException("验证类型不能为空"); |
| | | throw new YamiShopBindException("Verification type is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(verifcode)) { |
| | | throw new YamiShopBindException("验证码不能为空"); |
| | | throw new YamiShopBindException("Verification code is required"); |
| | | } |
| | | String loginPartyId = SecurityUtils.getUser().getUserId(); |
| | | User party = userService.getById(loginPartyId); |
| | |
| | | String errMsg = ""; |
| | | if ("1".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMobile()) || false == party.isUserMobileBind() ? "" : party.getUserMobile(); |
| | | errMsg = "未绑定手机号"; |
| | | errMsg = "Phone number is not bound"; |
| | | } else if ("2".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getUserMail()) || false == party.isMailBind() ? "" : party.getUserMail(); |
| | | errMsg = "未绑定邮箱"; |
| | | errMsg = "Email is not bound"; |
| | | } else if ("3".equals(verifcode_type)) { |
| | | key = StringUtils.isEmptyString(party.getGoogleAuthSecret()) || false == party.isGoogleAuthBind() ? "" : party.getGoogleAuthSecret(); |
| | | errMsg = "未绑定谷歌验证器"; |
| | | errMsg = "Google Authenticator is not bound"; |
| | | } |
| | | if (StringUtils.isEmptyString(key)) { |
| | | throw new YamiShopBindException(errMsg); |
| | |
| | | // 如果是演示用户,则不判断验证码 |
| | | if (!"GUEST".contentEquals(party.getRoleName())) { |
| | | if (!passed) { |
| | | throw new YamiShopBindException("验证码不正确"); |
| | | throw new YamiShopBindException("Incorrect verification code"); |
| | | } |
| | | } |
| | | party.setSafePassword(passwordEncoder.encode(safeword)); |
| | | // 更新密码 |
| | | userService.updateById(party); |
| | | return Result.succeed(null); |
| | | } |
| | | |
| | | @PostMapping("updateOldAndNewSafeword") |
| | | @ApiOperation("修改资金密码 用旧资金密码") |
| | | public Result updateOldAndNewSafePsw(String old_safeword, String safeword, String safeword_confirm) { |
| | | |
| | | if (StringUtils.isEmptyString(old_safeword)) { |
| | | throw new YamiShopBindException("Old fund password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("New fund password is required"); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword_confirm)) { |
| | | throw new YamiShopBindException("Fund password confirmation is required"); |
| | | } |
| | | if (old_safeword.length() < 6 || old_safeword.length() > 12 || safeword.length() < 6 || safeword.length() > 12) { |
| | | throw new YamiShopBindException("Password must be 6-12 characters"); |
| | | } |
| | | User secUser = userService.getById(SecurityUtils.getUser().getUserId()); |
| | | if (!passwordEncoder.matches(old_safeword, secUser.getSafePassword())) { |
| | | throw new YamiShopBindException("Incorrect old password"); |
| | | } |
| | | if (!safeword.equals(safeword_confirm)) { |
| | | throw new YamiShopBindException("New passwords do not match"); |
| | | } |
| | | secUser.setSafePassword(passwordEncoder.encode(safeword_confirm)); |
| | | userService.updateById(secUser); |
| | | return Result.succeed(null); |
| | | } |
| | | |
| | |
| | | String remark) { |
| | | |
| | | if (StringUtils.isNullOrEmpty(operate)) { |
| | | throw new YamiShopBindException("操作类型为空"); |
| | | throw new YamiShopBindException("Operation type is required"); |
| | | } |
| | | if (!StringUtils.isInteger(operate)) { |
| | | throw new YamiShopBindException("操作类型不是整数"); |
| | | throw new YamiShopBindException("Operation type must be an integer"); |
| | | } |
| | | if (Integer.valueOf(operate).intValue() < 0) { |
| | | throw new YamiShopBindException("操作类型不能小于0"); |
| | | throw new YamiShopBindException("Operation type cannot be negative"); |
| | | } |
| | | |
| | | if(!StrUtil.isEmpty(remark)){ |
| | | if (remark.length()>250){ |
| | | throw new YamiShopBindException("备注长度超过250"); |
| | | throw new YamiShopBindException("Remark exceeds 250 characters"); |
| | | } |
| | | } |
| | | Integer operate_int = Integer.valueOf(operate); |
| | |
| | | String code = request.getParameter("code"); |
| | | String key = request.getParameter("key"); |
| | | if (!LockFilter.add(username)) { |
| | | return Result.failed("重复提交"); |
| | | return Result.failed("Duplicate submission"); |
| | | } |
| | | String error = validateParamUsername(username, password); |
| | | if (!StringUtils.isNullOrEmpty(error)) { |
| | | return Result.failed(error); |
| | | } |
| | | if (StringUtils.isEmptyString(safeword)) { |
| | | throw new YamiShopBindException("资金密码不能为空"); |
| | | throw new YamiShopBindException("Fund password is required"); |
| | | } |
| | | if (safeword.length() != 6 || !Strings.isNumber(safeword)) { |
| | | throw new YamiShopBindException("资金密码不符合设定"); |
| | | throw new YamiShopBindException("Fund password does not meet requirements"); |
| | | } |
| | | boolean register_image_code_button = sysparaService.find("register_image_code_button").getBoolean(); |
| | | if (register_image_code_button) { |
| | | if (StringUtils.isEmptyString(code) || StringUtils.isEmptyString(key)) { |
| | | throw new BusinessException("验证码不能为空"); |
| | | throw new BusinessException("Verification code is required"); |
| | | } else { |
| | | String codeText = redisTemplate.opsForValue().get(key).toString(); |
| | | String decryptCode = ImageVerificationEndecrypt.decryptDES(code, key + "key"); |
| | | if (!decryptCode.equalsIgnoreCase(codeText)) { |
| | | log.info("ip:{" + IPHelper.getIpAddr() + "},图片验证码不正确,paramcode:{" + decryptCode + "},truecode:{" |
| | | + codeText + "}"); |
| | | throw new BusinessException("验证码错误"); |
| | | throw new BusinessException("Incorrect verification code"); |
| | | } |
| | | } |
| | | } |
| | |
| | | private String validateParamUsername(String username, String password) { |
| | | |
| | | if (StringUtils.isNullOrEmpty(username)) { |
| | | return "用户名不能为空"; |
| | | return "Username is required"; |
| | | } |
| | | if (StringUtils.isNullOrEmpty(password)) { |
| | | return "登录密码不能为空"; |
| | | return "Login password is required"; |
| | | } |
| | | if (!RegexUtil.isUSername(username)) { |
| | | return "用户名必须由数字和英文字母组成"; |
| | | return "Username must contain letters and numbers"; |
| | | } |
| | | int min = 6; |
| | | int max = 12; |
| | | int max_name = 24; |
| | | if (!RegexUtil.length(username, min, max_name)) { |
| | | return "用户名不符合设定"; |
| | | return "Username does not meet requirements"; |
| | | } |
| | | if (!RegexUtil.length(password, min, max)) { |
| | | return "登陆密码长度不符合设定"; |
| | | return "Login password length does not meet requirements"; |
| | | } |
| | | // if (!RegexUtil.isDigits(this.password)) { |
| | | // // 只能输入数字 |