Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
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
zengtianlai3
ioc_sixiang_license
Commits
c3a5aa34
Commit
c3a5aa34
authored
Jun 14, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token失效
parent
5543af64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+3
-2
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+5
-7
No files found.
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
c3a5aa34
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -71,7 +72,7 @@ public class LoginController {
...
@@ -71,7 +72,7 @@ public class LoginController {
@GetMapping
(
"fail"
)
@GetMapping
(
"fail"
)
@ApiIgnore
@ApiIgnore
public
ResResult
fail
()
{
public
ResResult
fail
(
HttpServletRequest
request
)
{
return
ResResult
.
fail
().
msg
(
"认证信息非法"
);
return
ResResult
.
fail
().
msg
(
request
.
getAttribute
(
"msg"
).
toString
()
);
}
}
}
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
c3a5aa34
...
@@ -55,27 +55,25 @@ public class JwtFilter implements Filter {
...
@@ -55,27 +55,25 @@ public class JwtFilter implements Filter {
}
}
if
(
token
==
null
)
{
if
(
token
==
null
)
{
String
resultStr
=
JSON
.
toJSONString
(
ResResult
.
fail
().
msg
(
"认证信息不能为空"
)
);
request
.
setAttribute
(
"msg"
,
"认证信息不能为空"
);
re
sponse
.
getWriter
().
write
(
resultStr
);
re
quest
.
getRequestDispatcher
(
"/fail"
).
forward
(
request
,
response
);
return
;
return
;
}
else
{
}
else
{
DecodedJWT
jwt
=
JwtUtil
.
verifyToken
(
token
);
DecodedJWT
jwt
=
JwtUtil
.
verifyToken
(
token
);
if
(
jwt
==
null
)
{
if
(
jwt
==
null
)
{
request
.
setAttribute
(
"msg"
,
"认证信息非法"
);
request
.
getRequestDispatcher
(
"/fail"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/fail"
).
forward
(
request
,
response
);
return
;
return
;
}
else
{
}
else
{
Map
<
String
,
Claim
>
userData
=
jwt
.
getClaims
();
Map
<
String
,
Claim
>
userData
=
jwt
.
getClaims
();
if
(
userData
==
null
)
{
if
(
userData
==
null
)
{
String
resultStr
=
JSON
.
toJSONString
(
ResResult
.
fail
().
msg
(
"认证信息非法"
)
);
request
.
setAttribute
(
"msg"
,
"认证信息非法"
);
re
sponse
.
getWriter
().
write
(
resultStr
);
re
quest
.
getRequestDispatcher
(
"/fail"
).
forward
(
request
,
response
);
return
;
return
;
}
}
String
userId
=
userData
.
get
(
"userId"
).
asString
();
String
userId
=
userData
.
get
(
"userId"
).
asString
();
String
userName
=
userData
.
get
(
"userName"
).
asString
();
String
userName
=
userData
.
get
(
"userName"
).
asString
();
String
password
=
userData
.
get
(
"password"
).
asString
();
String
password
=
userData
.
get
(
"password"
).
asString
();
// //拦截器 拿到用户信息,放到request中
// request.setAttribute("userName", userName);
// request.setAttribute("password", password);
LoginUser
loginUser
=
new
LoginUser
(
userId
,
userName
,
password
);
LoginUser
loginUser
=
new
LoginUser
(
userId
,
userName
,
password
);
UserUtils
.
setLoginUser
(
loginUser
);
UserUtils
.
setLoginUser
(
loginUser
);
...
...
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