Commit 4bef1489 authored by 技术部-任文超's avatar 技术部-任文超

Merge remote-tracking branch 'origin/keys' into feature/20171113-QGCPGL-467

parents 4a518ace ba7c131b
...@@ -88,7 +88,7 @@ public class CaptchaNewValidateAdvisor { ...@@ -88,7 +88,7 @@ public class CaptchaNewValidateAdvisor {
Long countIP = countIP(clientIp); Long countIP = countIP(clientIp);
Long countPhone = countPhone(phoneNo); Long countPhone = countPhone(phoneNo);
Long countDeviceId = countDeviceId(deviceId); Long countDeviceId = countDeviceId(deviceId);
LOGGER.info("使用图形验证码, registerFrom={}, clientIp={},手机号次数:{},设备次数:{},ip次数:{},phone:{}", registerFrom, clientIp,countPhone,countDeviceId,countIP,phoneNo);
if (countIP > Constants.Image_Need_Count || countPhone > Constants.Image_Need_Count || countDeviceId > Constants.Image_Need_Count) { if (countIP > Constants.Image_Need_Count || countPhone > Constants.Image_Need_Count || countDeviceId > Constants.Image_Need_Count) {
if (shouldSkipCaptchaValidate(registerFrom, captchaId, captchaValue)) { if (shouldSkipCaptchaValidate(registerFrom, captchaId, captchaValue)) {
...@@ -115,6 +115,7 @@ public class CaptchaNewValidateAdvisor { ...@@ -115,6 +115,7 @@ public class CaptchaNewValidateAdvisor {
} }
return result; return result;
} }
LOGGER.info("使用错误图形验证码, registerFrom={}, clientIp={},手机号次数:{},设备次数:{},ip次数:{},phone:{}", registerFrom, clientIp,countPhone,countDeviceId,countIP,phoneNo);
result.setMsg("请输入图形验证码"); result.setMsg("请输入图形验证码");
return result; return result;
......
...@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; ...@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -70,12 +71,12 @@ public class RedisCaptchaStore implements CaptchaStore { ...@@ -70,12 +71,12 @@ public class RedisCaptchaStore implements CaptchaStore {
@Override @Override
public int getSize() { public int getSize() {
return getKeys().size(); return 0;
} }
@Override @Override
public Collection getKeys() { public Collection getKeys() {
return stringRedisTemplate.keys(Constants.REDIS_CAPTCHA_KEY_PATTERN); return Collections.emptyList();
} }
@Override @Override
......
...@@ -732,6 +732,24 @@ public class InnerController implements IBaseController { ...@@ -732,6 +732,24 @@ public class InnerController implements IBaseController {
return JsonResult.buildSuccessResult("用户已禁用.", user.getEnable() == false); return JsonResult.buildSuccessResult("用户已禁用.", user.getEnable() == false);
} }
/**
* 清除用户缓存信息
* @param phoneNo
* @return
*/
@RequestMapping("/flush/cache")
public JsonResult flushCache(String phoneNo) {
if (!ValidationUtil.validatePhoneNo(phoneNo)) {
return JsonResult.buildErrorStateResult("手机号格式错误", null);
}
User user = userService.findByPhoneInDb(phoneNo);
if (null == user) {
return JsonResult.buildErrorStateResult("未查询到该用户,用户phoneNo:" + phoneNo, null);
}
sessionService.deleteByUserId(user.getId());
LOGGER.info("删除用户缓存信息,phoneNo:{},userId:{},", user.getPhoneNo(), user.getId());
return JsonResult.buildSuccessResult("用户缓存信息已经删除", null);
}
@RequestMapping("/user/spouse/save") @RequestMapping("/user/spouse/save")
public JsonResult saveSpouse(Long userId, MaritalStatus status, String spousePhone, String spouseName) { public JsonResult saveSpouse(Long userId, MaritalStatus status, String spousePhone, String spouseName) {
if (userId == null || userId == 0) { if (userId == null || userId == 0) {
......
...@@ -153,6 +153,7 @@ public class SmsController implements IBaseController { ...@@ -153,6 +153,7 @@ public class SmsController implements IBaseController {
smsService.getSmsSender().sendMsg(message); smsService.getSmsSender().sendMsg(message);
redisTemplate.opsForValue().set(key, uniqueId + ":" + randomCode, EXPIRE_MINUTES, TimeUnit.MINUTES); redisTemplate.opsForValue().set(key, uniqueId + ":" + randomCode, EXPIRE_MINUTES, TimeUnit.MINUTES);
deleteRetSendCode(phoneNo);//删除用户重置密码,多次错误逻辑 deleteRetSendCode(phoneNo);//删除用户重置密码,多次错误逻辑
return JsonResult.buildSuccessResult("发送成功", uniqueId); return JsonResult.buildSuccessResult("发送成功", uniqueId);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("发送短信验证码失败"); LOGGER.error("发送短信验证码失败");
...@@ -228,6 +229,7 @@ public class SmsController implements IBaseController { ...@@ -228,6 +229,7 @@ public class SmsController implements IBaseController {
redisTemplate.expire(verificationPhoneCountKey, Constants.ONE_DAY,TimeUnit.SECONDS); redisTemplate.expire(verificationPhoneCountKey, Constants.ONE_DAY,TimeUnit.SECONDS);
if (getPhoneVerificationCount > PHONE_MAX_PER_DAY) { if (getPhoneVerificationCount > PHONE_MAX_PER_DAY) {
LOGGER.info("您手机号已经达到获取今天短信验证码上限:phoneNo:{},deviceId:{},ip:{}",phoneNo,deviceId,getIp());
return JsonResult.buildErrorStateResult("今天已获取20次短信验证码,请使用语音验证码或明天再试", null); return JsonResult.buildErrorStateResult("今天已获取20次短信验证码,请使用语音验证码或明天再试", null);
} }
String verificationIPCountKey = getIp(); String verificationIPCountKey = getIp();
...@@ -238,12 +240,13 @@ public class SmsController implements IBaseController { ...@@ -238,12 +240,13 @@ public class SmsController implements IBaseController {
// // return JsonResult.buildErrorStateResult("您当前ip已经达到获取今天验证码上限", null); // // return JsonResult.buildErrorStateResult("您当前ip已经达到获取今天验证码上限", null);
// //} // //}
//} //}
LOGGER.info("请求短信新版本接口:phoneNo:{},deviceId:{},IP:{}",phoneNo,deviceId,getIp());
if (!StringUtils.isEmpty(deviceId)) { if (!StringUtils.isEmpty(deviceId)) {
String verificationDeviceCountKey = Constants.REDIS_SMS_DEVICE_COUNT + deviceId; String verificationDeviceCountKey = Constants.REDIS_SMS_DEVICE_COUNT + deviceId;
Long getDeviceVerificationCount = redisTemplate.opsForHash().increment(verificationDeviceCountKey, Constants.REDIS_SMS_DEVICE_COUNT, 1); Long getDeviceVerificationCount = redisTemplate.opsForHash().increment(verificationDeviceCountKey, Constants.REDIS_SMS_DEVICE_COUNT, 1);
redisTemplate.expire(verificationDeviceCountKey, Constants.ONE_DAY,TimeUnit.SECONDS); redisTemplate.expire(verificationDeviceCountKey, Constants.ONE_DAY,TimeUnit.SECONDS);
if (getDeviceVerificationCount > DEVICE_MAX_PER_DAY) { if (getDeviceVerificationCount > DEVICE_MAX_PER_DAY) {
LOGGER.info("您设备已经达到获取今天短信验证码上限:phoneNo:{},deviceId:{},ip:{}",phoneNo,verificationDeviceCountKey,getIp());
return JsonResult.buildErrorStateResult("您设备已经达到获取今天短信验证码上限", null); return JsonResult.buildErrorStateResult("您设备已经达到获取今天短信验证码上限", null);
} }
} }
...@@ -251,6 +254,7 @@ public class SmsController implements IBaseController { ...@@ -251,6 +254,7 @@ public class SmsController implements IBaseController {
String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo; String key = Constants.REDIS_PREFIX_VERIFICATION_CODE + phoneNo;
long expire = redisTemplate.getExpire(key, TimeUnit.MINUTES); long expire = redisTemplate.getExpire(key, TimeUnit.MINUTES);
if (expire >= EXPIRE_MINUTES - 1) { if (expire >= EXPIRE_MINUTES - 1) {
LOGGER.info("sendVerificationCode2New一分钟内重复获取:phoneNo:{},deviceId:{},ip:{}",phoneNo,deviceId,getIp());
return JsonResult.buildSuccessResult("发送成功", null); return JsonResult.buildSuccessResult("发送成功", null);
} }
String randomCode = smsIsDebug ? "0000" : String.valueOf(random.nextInt(8999) + 1000); String randomCode = smsIsDebug ? "0000" : String.valueOf(random.nextInt(8999) + 1000);
...@@ -269,9 +273,10 @@ public class SmsController implements IBaseController { ...@@ -269,9 +273,10 @@ public class SmsController implements IBaseController {
if(needImageVlidate(verificationIPCountKey,deviceId,phoneNo)){ if(needImageVlidate(verificationIPCountKey,deviceId,phoneNo)){
return JsonResult.buildSuccessResult("发送成功", uniqueId,0003L); return JsonResult.buildSuccessResult("发送成功", uniqueId,0003L);
} }
LOGGER.info("sendVerificationCode2New获取短信成功:phone:{},deviceId:{},ip:{}",phoneNo,deviceId,getIp());
return JsonResult.buildSuccessResult("发送成功", uniqueId); return JsonResult.buildSuccessResult("发送成功", uniqueId);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("发送短信验证码失败"); LOGGER.error("发送短信验证码失败:phone:{},deviceId:{},ip:{}",phoneNo,deviceId,getIp());
return JsonResult.buildErrorStateResult("发送失败", null); return JsonResult.buildErrorStateResult("发送失败", null);
} }
} }
......
...@@ -432,8 +432,16 @@ public class UserController implements IBaseController { ...@@ -432,8 +432,16 @@ public class UserController implements IBaseController {
*/ */
@RequestMapping("/exists_token") @RequestMapping("/exists_token")
public JsonResult checkToken(@RequestParam String token) { public JsonResult checkToken(@RequestParam String token) {
if(StringUtils.isEmpty(token)){
return JsonResult.buildSuccessResult(null,false);
}
if(token.contains("*")){
return JsonResult.buildSuccessResult(null,false);
}
String tokenKey = Constants.SESSION_PREFIX + token; String tokenKey = Constants.SESSION_PREFIX + token;
return JsonResult.buildSuccessResult(null, stringRedisTemplate.hasKey(tokenKey)); String tokenKey2 = Constants.Session.USER_SESSION_CACHE + token;
return JsonResult.buildSuccessResult(null, stringRedisTemplate.hasKey(tokenKey)||stringRedisTemplate.hasKey(tokenKey2));
} }
......
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