Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
45a461cd
Commit
45a461cd
authored
Nov 13, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
cd2e521d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
CaptchaNewValidateAdvisor.java
...tgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
+2
-1
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+7
-2
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
View file @
45a461cd
...
@@ -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次数:{}"
,
registerFrom
,
request
.
getRemoteAddr
(),
countIP
,
countDeviceId
,
countIP
);
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次数:{}"
,
registerFrom
,
request
.
getRemoteAddr
(),
countIP
,
countDeviceId
,
countIP
);
result
.
setMsg
(
"请输入图形验证码"
);
result
.
setMsg
(
"请输入图形验证码"
);
return
result
;
return
result
;
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
45a461cd
...
@@ -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
,
0003
L
);
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
,
0003
L
);
}
}
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
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment