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
534a8130
Commit
534a8130
authored
Aug 29, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改增加三次获取成功提醒
parent
008a0860
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
22 deletions
+42
-22
CaptchaNewValidateAdvisor.java
...tgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
+2
-0
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+40
-22
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
View file @
534a8130
...
@@ -86,7 +86,9 @@ public class CaptchaNewValidateAdvisor {
...
@@ -86,7 +86,9 @@ 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
);
if
(
countIP
>
3
||
countPhone
>
3
||
countDeviceId
>
3
)
{
if
(
countIP
>
3
||
countPhone
>
3
||
countDeviceId
>
3
)
{
if
(
shouldSkipCaptchaValidate
(
registerFrom
,
captchaId
,
captchaValue
))
{
if
(
shouldSkipCaptchaValidate
(
registerFrom
,
captchaId
,
captchaValue
))
{
LOGGER
.
info
(
"使用超级图形验证码校验, registerFrom={}, clientIp={}"
,
registerFrom
,
request
.
getRemoteAddr
());
LOGGER
.
info
(
"使用超级图形验证码校验, registerFrom={}, clientIp={}"
,
registerFrom
,
request
.
getRemoteAddr
());
return
pjp
.
proceed
();
return
pjp
.
proceed
();
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
534a8130
...
@@ -41,9 +41,9 @@ public class SmsController implements IBaseController {
...
@@ -41,9 +41,9 @@ public class SmsController implements IBaseController {
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
private
RedisTemplate
<
String
,
String
>
redisTemplate
;
@Value
(
"${sms.is.debug}"
)
@Value
(
"${sms.is.debug}"
)
private
boolean
smsIsDebug
;
private
boolean
smsIsDebug
;
private
static
final
String
IMAGE_IP_COUNT
=
"image:ip"
;
private
static
final
String
IMAGE_PHONE_COUNT
=
"image:phone"
;
private
static
final
String
IMAGE_DEVICEID_COUNT
=
"image:deviceId:"
;
/**
/**
* 短信验证码: for H5
* 短信验证码: for H5
...
@@ -176,6 +176,7 @@ public class SmsController implements IBaseController {
...
@@ -176,6 +176,7 @@ public class SmsController implements IBaseController {
try
{
try
{
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
);
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
);
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"发送语音短信验证码失败"
);
LOGGER
.
error
(
"发送语音短信验证码失败"
);
...
@@ -189,14 +190,14 @@ public class SmsController implements IBaseController {
...
@@ -189,14 +190,14 @@ public class SmsController implements IBaseController {
@CaptchaNewValidator
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_voice_new"
)
@RequestMapping
(
"/send_login_code_voice_new"
)
public
JsonResult
sendLoginSmsCodeNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
public
JsonResult
sendLoginSmsCodeNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
String
usage
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
String
usage
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
if
(
StringUtils
.
isEmpty
(
usage
)
||
!
"6"
.
equals
(
usage
))
{
if
(
StringUtils
.
isEmpty
(
usage
)
||
!
"6"
.
equals
(
usage
))
{
LOGGER
.
error
(
"参数校验失败,用户登录语音验证码usage参数为{}"
,
usage
);
LOGGER
.
error
(
"参数校验失败,用户登录语音验证码usage参数为{}"
,
usage
);
return
JsonResult
.
buildErrorStateResult
(
"参数校验失败."
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数校验失败."
,
null
);
}
}
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2VoiceNew
(
phoneNo
,
usage
,
deviceId
);
return
sendVerificationCode2VoiceNew
(
phoneNo
,
usage
,
deviceId
);
}
}
/**
/**
...
@@ -204,34 +205,34 @@ public class SmsController implements IBaseController {
...
@@ -204,34 +205,34 @@ public class SmsController implements IBaseController {
*/
*/
@CaptchaNewValidator
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_new"
)
@RequestMapping
(
"/send_login_code_new"
)
public
JsonResult
sendLoginCodeVoiceNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
public
JsonResult
sendLoginCodeVoiceNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
);
}
}
/**
/**
* 新版本验证码
* 新版本验证码
*/
*/
private
JsonResult
sendVerificationCode2New
(
String
phoneNo
,
String
deviceId
)
{
private
JsonResult
sendVerificationCode2New
(
String
phoneNo
,
String
deviceId
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
}
}
String
verificationPhoneCountKey
=
Constants
.
REDIS_SMS_CODE_COUNT
+
phoneNo
;
String
verificationPhoneCountKey
=
Constants
.
REDIS_SMS_CODE_COUNT
+
phoneNo
;
Long
getPhoneVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationPhoneCountKey
,
Constants
.
REDIS_SMS_CODE_COUNT
,
1
);
Long
getPhoneVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationPhoneCountKey
,
Constants
.
REDIS_SMS_CODE_COUNT
,
1
);
if
(
getPhoneVerificationCount
>
20
)
{
if
(
getPhoneVerificationCount
>
20
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取20次短信验证码,请使用语音验证码或明天再试"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"今天已获取20次短信验证码,请使用语音验证码或明天再试"
,
null
);
}
}
String
verificationIPCountKey
=
getIp
();
String
verificationIPCountKey
=
getIp
();
if
(!
StringUtils
.
isEmpty
(
verificationIPCountKey
))
{
if
(!
StringUtils
.
isEmpty
(
verificationIPCountKey
))
{
Long
getIPVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationIPCountKey
,
Constants
.
REDIS_SMS_IP_COUNT
,
1
);
Long
getIPVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationIPCountKey
,
Constants
.
REDIS_SMS_IP_COUNT
,
1
);
if
(
getIPVerificationCount
>
5000
)
{
if
(
getIPVerificationCount
>
5000
)
{
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
}
}
}
}
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
);
if
(
getDeviceVerificationCount
>
20
)
{
if
(
getDeviceVerificationCount
>
20
)
{
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
}
}
...
@@ -254,6 +255,9 @@ public class SmsController implements IBaseController {
...
@@ -254,6 +255,9 @@ public class SmsController implements IBaseController {
//smsService.getSmsSender().sendConfirmableMessage(confirmableMsg);
//smsService.getSmsSender().sendConfirmableMessage(confirmableMsg);
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
);
if
(
needImageVlidate
(
verificationIPCountKey
,
deviceId
,
phoneNo
)){
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
,
0003
L
);
}
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
);
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"发送短信验证码失败"
);
LOGGER
.
error
(
"发送短信验证码失败"
);
...
@@ -264,23 +268,23 @@ public class SmsController implements IBaseController {
...
@@ -264,23 +268,23 @@ public class SmsController implements IBaseController {
/**
/**
* 新版本语音验证码
* 新版本语音验证码
*/
*/
private
JsonResult
sendVerificationCode2VoiceNew
(
String
phoneNo
,
String
usage
,
String
deviceId
)
{
private
JsonResult
sendVerificationCode2VoiceNew
(
String
phoneNo
,
String
usage
,
String
deviceId
)
{
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
if
(
getVerificationCount
>
5
)
{
if
(
getVerificationCount
>
5
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
}
}
String
verificationIPCountKey
=
getIp
();
String
verificationIPCountKey
=
getIp
();
if
(!
StringUtils
.
isEmpty
(
verificationIPCountKey
))
{
if
(!
StringUtils
.
isEmpty
(
verificationIPCountKey
))
{
Long
getIPVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationIPCountKey
,
Constants
.
REDIS_SMS_IP_COUNT
,
1
);
Long
getIPVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationIPCountKey
,
Constants
.
REDIS_SMS_IP_COUNT
,
1
);
if
(
getIPVerificationCount
>
5000
)
{
if
(
getIPVerificationCount
>
5000
)
{
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
}
}
}
}
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
);
if
(
getDeviceVerificationCount
>
20
)
{
if
(
getDeviceVerificationCount
>
20
)
{
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上线"
,
null
);
}
}
...
@@ -301,6 +305,9 @@ public class SmsController implements IBaseController {
...
@@ -301,6 +305,9 @@ public class SmsController implements IBaseController {
try
{
try
{
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
);
if
(
needImageVlidate
(
verificationIPCountKey
,
deviceId
,
phoneNo
)){
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
,
0003
L
);
}
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
);
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"发送语音短信验证码失败"
);
LOGGER
.
error
(
"发送语音短信验证码失败"
);
...
@@ -308,6 +315,17 @@ public class SmsController implements IBaseController {
...
@@ -308,6 +315,17 @@ public class SmsController implements IBaseController {
}
}
}
}
private
boolean
needImageVlidate
(
String
clientIp
,
String
deviceId
,
String
phoneNo
)
{
boolean
need
=
false
;
String
countIP
=
redisTemplate
.
opsForValue
().
get
(
IMAGE_IP_COUNT
+
clientIp
);
String
countDeviceId
=
redisTemplate
.
opsForValue
().
get
(
IMAGE_DEVICEID_COUNT
+
deviceId
);
String
countPhoneNo
=
redisTemplate
.
opsForValue
().
get
(
IMAGE_PHONE_COUNT
+
phoneNo
);
Long
ip
=
StringUtils
.
isBlank
(
countIP
)
?
1L
:
Long
.
valueOf
(
countIP
);
Long
devId
=
StringUtils
.
isBlank
(
countDeviceId
)
?
1L
:
Long
.
valueOf
(
countDeviceId
);
Long
phNo
=
StringUtils
.
isBlank
(
countPhoneNo
)
?
1L
:
Long
.
valueOf
(
countPhoneNo
);
if
(
ip
>=
3L
||
devId
>=
3L
||
phNo
>=
3L
)
{
need
=
true
;
}
return
need
;
}
}
}
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