Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
youjj
cloud-platform
Commits
55d8e4e7
Commit
55d8e4e7
authored
Dec 21, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
123
parent
1d8b0507
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
RedisKey.java
.../com/github/wxiaoqi/security/admin/constant/RedisKey.java
+2
-0
AppPermissionService.java
...aoqi/security/admin/rpc/service/AppPermissionService.java
+35
-0
No files found.
ace-modules/ace-admin-api/src/main/java/com/github/wxiaoqi/security/admin/constant/RedisKey.java
View file @
55d8e4e7
...
@@ -7,4 +7,6 @@ public class RedisKey {
...
@@ -7,4 +7,6 @@ public class RedisKey {
*/
*/
public
static
final
String
CONSTANT_CODE_PREFIX
=
"cache:mobilecode:"
;
public
static
final
String
CONSTANT_CODE_PREFIX
=
"cache:mobilecode:"
;
public
static
final
String
CONSTANT_ERROR_PREFIX
=
"cache:mobileerror:"
;
}
}
ace-modules/ace-admin/src/main/java/com/github/wxiaoqi/security/admin/rpc/service/AppPermissionService.java
View file @
55d8e4e7
...
@@ -118,6 +118,9 @@ public class AppPermissionService {
...
@@ -118,6 +118,9 @@ public class AppPermissionService {
private
AppUserAlipayBiz
alipayBiz
;
private
AppUserAlipayBiz
alipayBiz
;
private
static
final
Integer
maxNumber
=
5
;
public
AppUserInfo
validate
(
String
username
,
String
password
)
{
public
AppUserInfo
validate
(
String
username
,
String
password
)
{
AppUserInfo
info
=
new
AppUserInfo
();
AppUserInfo
info
=
new
AppUserInfo
();
AppUserLogin
user
=
appUserLoginBiz
.
checkeUserLogin
(
username
);
AppUserLogin
user
=
appUserLoginBiz
.
checkeUserLogin
(
username
);
...
@@ -262,6 +265,9 @@ public class AppPermissionService {
...
@@ -262,6 +265,9 @@ public class AppPermissionService {
}
}
}
}
}
}
if
(
checkErrorNum
(
username
)){
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"验证码超过错误次数"
);
}
String
redisLockKey
=
RedisKey
.
CONSTANT_CODE_PREFIX
+
username
+
mobilecode
;
String
redisLockKey
=
RedisKey
.
CONSTANT_CODE_PREFIX
+
username
+
mobilecode
;
String
mobilecodeRedis
=
userRedisTemplate
.
opsForValue
().
get
(
redisLockKey
)
==
null
?
""
:
userRedisTemplate
.
opsForValue
().
get
(
redisLockKey
).
toString
();
String
mobilecodeRedis
=
userRedisTemplate
.
opsForValue
().
get
(
redisLockKey
)
==
null
?
""
:
userRedisTemplate
.
opsForValue
().
get
(
redisLockKey
).
toString
();
log
.
info
(
"注册接口,获取redis中的验证码:"
+
mobilecodeRedis
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
log
.
info
(
"注册接口,获取redis中的验证码:"
+
mobilecodeRedis
+
"---time===="
+
System
.
currentTimeMillis
()/
1000L
);
...
@@ -587,6 +593,7 @@ public class AppPermissionService {
...
@@ -587,6 +593,7 @@ public class AppPermissionService {
// 获取到缓存的验证码后要先清空缓存对应键的值
// 获取到缓存的验证码后要先清空缓存对应键的值
userRedisTemplate
.
delete
(
redisLockKey
);
userRedisTemplate
.
delete
(
redisLockKey
);
if
(
StringUtils
.
isBlank
(
mobilecodeRedis
))
{
if
(
StringUtils
.
isBlank
(
mobilecodeRedis
))
{
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
NOTEXIST_CODE
,
"验证码错误"
);
return
JsonResultUtil
.
createFailedResult
(
ResultCode
.
NOTEXIST_CODE
,
"验证码错误"
);
}
}
Long
now
=
System
.
currentTimeMillis
()
/
1000
;
Long
now
=
System
.
currentTimeMillis
()
/
1000
;
...
@@ -671,6 +678,34 @@ public class AppPermissionService {
...
@@ -671,6 +678,34 @@ public class AppPermissionService {
}
}
public
void
setErrorNum
(
String
username
){
String
redisLockKey
=
RedisKey
.
CONSTANT_ERROR_PREFIX
+
username
;
Integer
number
=
getErrorNum
(
username
,
redisLockKey
);
userRedisTemplate
.
delete
(
redisLockKey
);
Boolean
suc
=
userRedisTemplate
.
opsForValue
().
setIfAbsent
(
redisLockKey
,
number
+
1
);
if
(
suc
)
{
userRedisTemplate
.
expire
(
redisLockKey
,
5
,
TimeUnit
.
MINUTES
);
//5分钟内过期
}
}
public
boolean
checkErrorNum
(
String
username
){
String
redisLockKey
=
RedisKey
.
CONSTANT_ERROR_PREFIX
+
username
;
Integer
number
=
getErrorNum
(
username
,
redisLockKey
);
if
(
number
>=
maxNumber
){
return
true
;
}
return
false
;
}
public
Integer
getErrorNum
(
String
username
,
String
redisLockKey
){
String
errorNum
=
userRedisTemplate
.
opsForValue
().
get
(
redisLockKey
)
==
null
?
"0"
:
userRedisTemplate
.
opsForValue
().
get
(
redisLockKey
).
toString
();
Integer
number
=
0
;
if
(
StringUtils
.
isNotBlank
(
errorNum
)){
number
=
Integer
.
parseInt
(
errorNum
);
}
return
number
;
}
/**
/**
* 校验手机号码是否已绑定微信
* 校验手机号码是否已绑定微信
*
*
...
...
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