Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
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
Administrator
solo
Commits
8e75346e
Commit
8e75346e
authored
Sep 10, 2012
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BAE 下服务端不校验评论验证码
parent
bc416c8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
23 deletions
+31
-23
core/src/main/java/org/b3log/solo/processor/CommentProcessor.java
.../main/java/org/b3log/solo/processor/CommentProcessor.java
+31
-23
No files found.
core/src/main/java/org/b3log/solo/processor/CommentProcessor.java
View file @
8e75346e
...
@@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -23,6 +23,8 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.RuntimeEnv
;
import
org.b3log.latke.annotation.RequestProcessing
;
import
org.b3log.latke.annotation.RequestProcessing
;
import
org.b3log.latke.annotation.RequestProcessor
;
import
org.b3log.latke.annotation.RequestProcessor
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsService
;
...
@@ -41,7 +43,7 @@ import org.json.JSONObject;
...
@@ -41,7 +43,7 @@ import org.json.JSONObject;
* Comment processor.
* Comment processor.
*
*
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.1.0.
7, Aug 9
, 2012
* @version 1.1.0.
8, Sep 10
, 2012
* @since 0.3.1
* @since 0.3.1
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -81,7 +83,7 @@ public final class CommentProcessor {
...
@@ -81,7 +83,7 @@ public final class CommentProcessor {
* including a request json object, for example,
* including a request json object, for example,
* <pre>
* <pre>
* {
* {
* "captcha": "",
* "captcha": "",
// optional if on BAE
* "oId": pageId,
* "oId": pageId,
* "commentName": "",
* "commentName": "",
* "commentEmail": "",
* "commentEmail": "",
...
@@ -113,18 +115,21 @@ public final class CommentProcessor {
...
@@ -113,18 +115,21 @@ public final class CommentProcessor {
return
;
return
;
}
}
final
String
captcha
=
requestJSONObject
.
optString
(
CaptchaProcessor
.
CAPTCHA
);
if
(
RuntimeEnv
.
BAE
!=
Latkes
.
getRuntimeEnv
())
{
final
HttpSession
session
=
httpServletRequest
.
getSession
(
false
);
final
String
captcha
=
requestJSONObject
.
optString
(
CaptchaProcessor
.
CAPTCHA
);
if
(
null
!=
session
)
{
final
String
storedCaptcha
=
(
String
)
session
.
getAttribute
(
CaptchaProcessor
.
CAPTCHA
);
if
(
null
==
storedCaptcha
||
!
storedCaptcha
.
equals
(
captcha
))
{
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"captchaErrorLabel"
));
return
;
final
HttpSession
session
=
httpServletRequest
.
getSession
(
false
);
}
if
(
null
!=
session
)
{
final
String
storedCaptcha
=
(
String
)
session
.
getAttribute
(
CaptchaProcessor
.
CAPTCHA
);
if
(
null
==
storedCaptcha
||
!
storedCaptcha
.
equals
(
captcha
))
{
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"captchaErrorLabel"
));
session
.
removeAttribute
(
CaptchaProcessor
.
CAPTCHA
);
return
;
}
session
.
removeAttribute
(
CaptchaProcessor
.
CAPTCHA
);
}
}
}
try
{
try
{
...
@@ -193,20 +198,23 @@ public final class CommentProcessor {
...
@@ -193,20 +198,23 @@ public final class CommentProcessor {
return
;
return
;
}
}
final
String
captcha
=
requestJSONObject
.
optString
(
CaptchaProcessor
.
CAPTCHA
);
if
(
RuntimeEnv
.
BAE
!=
Latkes
.
getRuntimeEnv
())
{
final
HttpSession
session
=
httpServletRequest
.
getSession
(
false
);
final
String
captcha
=
requestJSONObject
.
optString
(
CaptchaProcessor
.
CAPTCHA
);
if
(
null
!=
session
)
{
final
String
storedCaptcha
=
(
String
)
session
.
getAttribute
(
CaptchaProcessor
.
CAPTCHA
);
if
(
null
==
storedCaptcha
||
!
storedCaptcha
.
equals
(
captcha
))
{
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"captchaErrorLabel"
));
return
;
final
HttpSession
session
=
httpServletRequest
.
getSession
(
false
);
}
if
(
null
!=
session
)
{
final
String
storedCaptcha
=
(
String
)
session
.
getAttribute
(
CaptchaProcessor
.
CAPTCHA
);
if
(
null
==
storedCaptcha
||
!
storedCaptcha
.
equals
(
captcha
))
{
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"captchaErrorLabel"
));
session
.
removeAttribute
(
CaptchaProcessor
.
CAPTCHA
)
;
return
;
}
}
session
.
removeAttribute
(
CaptchaProcessor
.
CAPTCHA
);
}
}
try
{
try
{
final
JSONObject
addResult
=
commentMgmtService
.
addArticleComment
(
requestJSONObject
);
final
JSONObject
addResult
=
commentMgmtService
.
addArticleComment
(
requestJSONObject
);
...
...
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