Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
afanti-open-api
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
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
java-ms
afanti-open-api
Commits
bb7f8a32
Commit
bb7f8a32
authored
Oct 09, 2024
by
严俊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token 验证失败时,返回401
parent
d8912115
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
TokenInterceptor.java
.../com/afanticar/afantiopenapi/config/TokenInterceptor.java
+11
-2
No files found.
src/main/java/com/afanticar/afantiopenapi/config/TokenInterceptor.java
View file @
bb7f8a32
...
...
@@ -36,12 +36,21 @@ public class TokenInterceptor implements HandlerInterceptor {
}
String
token
=
request
.
getHeader
(
"authorization"
);
if
(
StrUtil
.
isNotBlank
(
token
))
{
request
.
setAttribute
(
"clientId"
,
JWTUtils
.
getClientId
(
token
));
try
{
String
clientId
=
JWTUtils
.
getClientId
(
token
);
request
.
setAttribute
(
"clientId"
,
clientId
);
}
catch
(
Exception
e
){
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
setContentType
(
"application/json"
);
response
.
getWriter
().
append
(
JSONObject
.
toJSONString
(
BaseController
.
error
(
"401"
,
"认证失败,无效的token"
)));
return
false
;
}
}
else
{
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
setContentType
(
"application/json"
);
response
.
getWriter
().
append
(
JSONObject
.
toJSONString
(
BaseController
.
error
(
"401"
,
"认证失败"
)));
response
.
getWriter
().
append
(
JSONObject
.
toJSONString
(
BaseController
.
error
(
"401"
,
"认证失败
,无效的token
"
)));
return
false
;
}
return
true
;
...
...
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