Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
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
黄奎
mall.oytour.com
Commits
f67e2177
Commit
f67e2177
authored
Dec 22, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加表单重复验证
parent
0baa9691
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
ApiFilterAttribute.cs
Mall.WebApi/Filter/ApiFilterAttribute.cs
+14
-15
No files found.
Mall.WebApi/Filter/ApiFilterAttribute.cs
View file @
f67e2177
...
...
@@ -89,26 +89,25 @@ namespace Mall.WebApi.Filter
string
controllerName
=
actionContext
.
ActionDescriptor
.
RouteValues
[
"controller"
].
ToString
().
ToLower
();
string
actionName
=
actionContext
.
ActionDescriptor
.
RouteValues
[
"action"
].
ToString
().
ToLower
();
//string areaName = actionContext.ActionDescriptor.RouteValues["area"].ToString().ToLower();
if
(!
actionName
.
ToLower
().
Contains
(
"get"
))
{
string
cachedKey
=
SecurityHelper
.
MD5
(
string
.
Format
(
"cmd={0}&token={1}"
,
controllerName
+
"/"
+
actionName
,
token
));
try
{
//
if (UserReidsCache.Exists(cachedKey))//判断表单是否重复提交
//
{
//
actionContext.Result = new Microsoft.AspNetCore.Mvc.JsonResult(new ApiResult
//
{
//
resultCode = (int)ResultCode.FormRepeatSubmit,
//
message = "表单重复提交,请稍后再试",
//
data = null
//
});
//
}
//
else
//
{
// //默认2
秒钟之内不能重复提交
// UserReidsCache.Set(cachedKey, 1, 2
);
//
}
if
(
UserReidsCache
.
Exists
(
cachedKey
))
//判断表单是否重复提交
{
actionContext
.
Result
=
new
Microsoft
.
AspNetCore
.
Mvc
.
JsonResult
(
new
ApiResult
{
resultCode
=
(
int
)
ResultCode
.
FormRepeatSubmit
,
message
=
"表单重复提交,请稍后再试"
,
data
=
null
});
}
else
{
//默认3
秒钟之内不能重复提交
UserReidsCache
.
Set
(
cachedKey
,
1
,
3
);
}
}
catch
{
...
...
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