Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fzm-joying
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lei
fzm-joying
Commits
e4bb0ac2
Commit
e4bb0ac2
authored
Jul 16, 2021
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改拦截器判空规则
parent
f0082832
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
AuthenticationInterceptor.java
...com/fzm/common/interceptor/AuthenticationInterceptor.java
+6
-2
No files found.
joying-common/src/main/java/com/fzm/common/interceptor/AuthenticationInterceptor.java
View file @
e4bb0ac2
...
...
@@ -56,10 +56,13 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
if
(!
token
.
startsWith
(
TokenConstant
.
TOKEN_PREFIX
))
{
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
"非法token"
);
}
String
realToken
=
token
.
substring
(
TokenConstant
.
TOKEN_PREFIX
.
length
());
if
(
StringUtils
.
isBlank
(
realToken
)
||
"null"
.
equals
(
realToken
))
{
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
"请先登录"
);
}
if
(
JwtUtil
.
isTokenExpired
(
token
))
{
throw
GlobalException
.
newException
(
ResultCode
.
UNAUTHORIZED
,
"登录已过期"
);
}
String
realToken
=
token
.
substring
(
TokenConstant
.
TOKEN_PREFIX
.
length
());
String
appId
=
JwtUtil
.
getAppIdFromToken
(
token
);
Integer
userId
=
JwtUtil
.
getUserIdFromToken
(
token
);
AbstractUser
user
;
...
...
@@ -109,7 +112,8 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
}
public
static
void
main
(
String
[]
args
)
{
String
token
=
"Bearer
token121323433
"
;
String
token
=
"Bearer
null
"
;
System
.
out
.
println
(
token
.
substring
(
"Bearer "
.
length
()));
System
.
out
.
println
(
StringUtils
.
isBlank
(
token
.
substring
(
"Bearer "
.
length
())));
}
}
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