Commit 4e169c9c authored by hezhen's avatar hezhen

Merge branch 'master-customer-management' into dev

# Conflicts:
#	ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/constant/RedisKey.java
parents 604b9e94 a01d58ca
......@@ -7,10 +7,14 @@ public class RedisKey {
*/
public static final String CONSTANT_CODE_PREFIX ="cache:mobilecode:";
/**
* 图片验证码
*/
public static final String CAPTCHA_PHONE_PREFIX = "captcha:phone:";
public static final String CONSTANT_ERROR_PREFIX ="cache:mobileerror:";
}
......@@ -118,6 +118,9 @@ public class AppPermissionService {
private AppUserAlipayBiz alipayBiz;
private static final Integer maxNumber=5;
public AppUserInfo validate(String username, String password) {
AppUserInfo info = new AppUserInfo();
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
......@@ -266,6 +269,9 @@ public class AppPermissionService {
}
}
}
/*if (checkErrorNum(username)){
return JsonResultUtil.createFailedResult(ResultCode.FAILED_CODE, "验证码超过错误次数");
}*/
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX + username + mobilecode;
String mobilecodeRedis = userRedisTemplate.opsForValue().get(redisLockKey) == null ? "" : userRedisTemplate.opsForValue().get(redisLockKey).toString();
log.info("注册接口,获取redis中的验证码:" + mobilecodeRedis+"---time===="+System.currentTimeMillis()/1000L);
......@@ -591,6 +597,7 @@ public class AppPermissionService {
// 获取到缓存的验证码后要先清空缓存对应键的值
userRedisTemplate.delete(redisLockKey);
if (StringUtils.isBlank(mobilecodeRedis)) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
Long now = System.currentTimeMillis() / 1000;
......@@ -675,6 +682,34 @@ public class AppPermissionService {
}
public void setErrorNum(String username){
String redisLockKey = RedisKey.CONSTANT_ERROR_PREFIX + username;
Integer number=getErrorNum(username,redisLockKey);
userRedisTemplate.delete(redisLockKey);
Boolean suc = userRedisTemplate.opsForValue().setIfAbsent(redisLockKey, number+1);
if (suc) {
userRedisTemplate.expire(redisLockKey, 5, TimeUnit.MINUTES);//5分钟内过期
}
}
public boolean checkErrorNum(String username){
String redisLockKey = RedisKey.CONSTANT_ERROR_PREFIX + username;
Integer number=getErrorNum(username,redisLockKey);
if (number>=maxNumber){
return true;
}
return false;
}
public Integer getErrorNum(String username,String redisLockKey){
String errorNum = userRedisTemplate.opsForValue().get(redisLockKey) == null ?"0": userRedisTemplate.opsForValue().get(redisLockKey).toString();
Integer number=0;
if (StringUtils.isNotBlank(errorNum)){
number=Integer.parseInt(errorNum);
}
return number;
}
/**
* 校验手机号码是否已绑定微信
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment