Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fj-captcha-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
郑磊
fj-captcha-service
Commits
e005e254
Commit
e005e254
authored
May 17, 2024
by
郑磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加回显验证数据接口
parent
15c701dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
CaptchaApplication.java
...n/java/com/fanjiao/captcha/server/CaptchaApplication.java
+13
-6
CaptchaController.java
...in/java/com/fanjiao/captcha/server/CaptchaController.java
+12
-0
No files found.
server/src/main/java/com/fanjiao/captcha/server/CaptchaApplication.java
View file @
e005e254
...
@@ -104,6 +104,18 @@ public class CaptchaApplication extends DefaultImageCaptchaApplication {
...
@@ -104,6 +104,18 @@ public class CaptchaApplication extends DefaultImageCaptchaApplication {
);
);
}
}
/**
* 获取二次校验数据
*
* @param key 验证码key
* @return 二次校验数据
*/
public
Map
<
String
,
Object
>
getSecondaryData
(
String
key
)
{
if
(
key
==
null
||
key
.
isEmpty
())
return
null
;
var
secondary
=
prop
.
getSecondary
();
return
getCacheStore
().
getAndRemoveCache
(
secondary
.
getKeyPrefix
().
concat
(
":"
).
concat
(
key
));
}
/**
/**
* 二次校验(使用)验证码
* 二次校验(使用)验证码
*
*
...
@@ -114,12 +126,7 @@ public class CaptchaApplication extends DefaultImageCaptchaApplication {
...
@@ -114,12 +126,7 @@ public class CaptchaApplication extends DefaultImageCaptchaApplication {
if
(
data
==
null
)
return
false
;
if
(
data
==
null
)
return
false
;
//读取二次校验数据
//读取二次校验数据
var
secondary
=
prop
.
getSecondary
();
var
verification
=
getSecondaryData
(
data
.
getKey
());
var
verification
=
getCacheStore
().
getAndRemoveCache
(
secondary
.
getKeyPrefix
().
concat
(
":"
).
concat
(
data
.
getKey
()));
if
(
verification
==
null
)
{
//如果没有校验数据,那么视为校验失败
return
false
;
}
//如果传入了ip,那就校验ip
//如果传入了ip,那就校验ip
String
ip
=
data
.
getIp
();
String
ip
=
data
.
getIp
();
...
...
server/src/main/java/com/fanjiao/captcha/server/CaptchaController.java
View file @
e005e254
...
@@ -119,4 +119,16 @@ public class CaptchaController {
...
@@ -119,4 +119,16 @@ public class CaptchaController {
return
Response
.
success
();
return
Response
.
success
();
}
}
@RequestMapping
(
"/verifyInfo"
)
public
Response
<?>
verifyCaptcha
(
@RequestParam
(
name
=
"key"
)
String
key
)
{
var
data
=
imageCaptchaApplication
.
getSecondaryData
(
key
);
if
(
data
==
null
)
{
return
Response
.
fail
(
"未验证的数据"
);
}
else
{
return
Response
.
success
(
data
);
}
}
}
}
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