验证码改为6位数
This commit is contained in:
@@ -204,11 +204,11 @@ public class MyUserController {
|
||||
}
|
||||
}
|
||||
|
||||
//生成随机五位数
|
||||
//生成随机六位数
|
||||
Random random = new Random();
|
||||
String i = random.nextInt(99999) + "";
|
||||
String i = random.nextInt(999999) + "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int j = 0; j < 5 - i.length(); j++) {
|
||||
for (int j = 0; j < 6 - i.length(); j++) {
|
||||
sb.append("0");
|
||||
}
|
||||
i = sb.toString() + i;
|
||||
@@ -237,9 +237,14 @@ public class MyUserController {
|
||||
return R.error(500,"验证码频率过高,请稍后再试!");
|
||||
}
|
||||
}
|
||||
//生成随机五位数
|
||||
//生成随机六位数
|
||||
Random random = new Random();
|
||||
String code = random.nextInt(99999) + "";
|
||||
String code = random.nextInt(999999) + "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int j = 0; j < 6 - code.length(); j++) {
|
||||
sb.append("0");
|
||||
}
|
||||
code = sb.toString() + code;
|
||||
String timeCode = code + "_"+System.currentTimeMillis();
|
||||
//redis 缓存验证码
|
||||
redisTemplate.opsForValue().set("RegistCode"+email,timeCode,5, TimeUnit.MINUTES);
|
||||
|
||||
Reference in New Issue
Block a user