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
a1b39974
Commit
a1b39974
authored
Dec 09, 2020
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图形验证码调整到1分钟给测试用
parent
4ff48c9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
7 deletions
+12
-7
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+1
-1
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+1
-1
ISmsService.java
...main/java/cn/quantgroup/xyqb/service/sms/ISmsService.java
+3
-2
SmsServiceImpl.java
...a/cn/quantgroup/xyqb/service/sms/impl/SmsServiceImpl.java
+7
-3
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
a1b39974
...
...
@@ -172,7 +172,7 @@ public interface Constants {
/**
* 图形验证码有效期
*/
Long
IMAGE_CAPTCHA_REDIS_CACHE_TIME_OUT
=
1
0
L
;
Long
IMAGE_CAPTCHA_REDIS_CACHE_TIME_OUT
=
1L
;
/**
* 默认随机密码长度
*/
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
a1b39974
...
...
@@ -616,7 +616,7 @@ public class UserController implements IBaseController {
private
void
verifyPhoneAndCodeForOnce
(
String
phoneNo
,
String
verificationCode
)
{
if
(!
smsService
.
verifyPhoneAndCode
(
phoneNo
,
verificationCode
))
{
// 是否需要重新发送短信验证码
if
(
smsService
.
needResendCode
(
phoneNo
,
VERIFICATION_CODE_FINITE_COUNT_NEW
))
{
if
(
smsService
.
needResendCode
(
phoneNo
,
VERIFICATION_CODE_FINITE_COUNT_NEW
,
false
))
{
throw
new
VerificationCodeErrorException
(
"验证码失效,请重新获取"
);
}
...
...
src/main/java/cn/quantgroup/xyqb/service/sms/ISmsService.java
View file @
a1b39974
...
...
@@ -34,12 +34,13 @@ public interface ISmsService {
boolean
needResendCode
(
String
phoneNo
);
/**
* 是否需要重新发送短信验证码
*
* @param phoneNo
* @param threshold
* @param isDelTryCount 是否删除尝试登录次数
* @return
*/
boolean
needResendCode
(
String
phoneNo
,
Long
threshold
);
boolean
needResendCode
(
String
phoneNo
,
Long
threshold
,
boolean
isDelTryCount
);
/**
* 删除验证码缓存
...
...
src/main/java/cn/quantgroup/xyqb/service/sms/impl/SmsServiceImpl.java
View file @
a1b39974
...
...
@@ -115,17 +115,21 @@ public class SmsServiceImpl implements ISmsService {
@Override
public
boolean
needResendCode
(
String
phoneNo
)
{
return
needResendCode
(
phoneNo
,
Constants
.
VERIFICATION_CODE_FINITE_COUNT
);
return
needResendCode
(
phoneNo
,
Constants
.
VERIFICATION_CODE_FINITE_COUNT
,
true
);
}
@Override
public
boolean
needResendCode
(
String
phoneNo
,
Long
threshold
)
{
public
boolean
needResendCode
(
String
phoneNo
,
Long
threshold
,
boolean
isDelTryCount
)
{
String
verificationCountKey
=
Constants
.
REDIS_VERIFICATION_COUNT
+
phoneNo
;
Long
getVerificationCount
=
stringRedisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
Constants
.
REDIS_VERIFICATION_COUNT
,
1
);
boolean
needResend
=
getVerificationCount
>=
threshold
;
if
(
needResend
)
{
deleteCodeFromCache
(
phoneNo
);
if
(
isDelTryCount
)
{
deleteCodeFromCache
(
phoneNo
);
}
else
{
deleteOnlyCodeFromCache
(
phoneNo
);
}
}
return
needResend
;
}
...
...
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