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
c6481e69
Commit
c6481e69
authored
Sep 07, 2022
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改token错误提示信息
parent
39998aee
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+6
-3
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+9
-4
No files found.
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
c6481e69
...
@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
...
@@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.jwt.JwtUtil
;
import
iot.sixiang.license.jwt.JwtUtil
;
import
iot.sixiang.license.jwt.LoginUser
;
import
iot.sixiang.license.jwt.LoginUser
;
...
@@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.*;
...
@@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.*;
import
springfox.documentation.annotations.ApiIgnore
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -136,9 +139,9 @@ public class LoginController {
...
@@ -136,9 +139,9 @@ public class LoginController {
@RequestMapping
(
value
=
"fail"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@RequestMapping
(
value
=
"fail"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
@ApiIgnore
@ApiIgnore
public
BaseResult
fail
()
{
public
BaseResult
fail
(
ServletRequest
servletRequest
)
{
String
msg
=
servletRequest
.
getAttribute
(
"msg"
).
toString
();
return
BaseResult
.
unauthorized
(
);
return
BaseResult
.
failed
().
setCodeValue
(
ResultCode
.
UNAUTHORIZED
.
getCode
()).
setMsgValue
(
msg
);
}
}
@ApiOperation
(
value
=
"发送验证码"
,
notes
=
"发送验证码到邮箱"
)
@ApiOperation
(
value
=
"发送验证码"
,
notes
=
"发送验证码到邮箱"
)
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
c6481e69
...
@@ -62,23 +62,28 @@ public class JwtFilter implements Filter {
...
@@ -62,23 +62,28 @@ public class JwtFilter implements Filter {
}
}
if
(
StringUtils
.
isEmpty
(
token
))
{
if
(
StringUtils
.
isEmpty
(
token
))
{
request
.
setAttribute
(
"msg"
,
"
认证信息
不能为空"
);
request
.
setAttribute
(
"msg"
,
"
token
不能为空"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
}
else
{
}
else
{
DecodedJWT
jwt
=
JwtUtil
.
verifyToken
(
token
);
DecodedJWT
jwt
=
JwtUtil
.
verifyToken
(
token
);
if
(
jwt
==
null
)
{
if
(
jwt
==
null
)
{
request
.
setAttribute
(
"msg"
,
"
认证信息非法
"
);
request
.
setAttribute
(
"msg"
,
"
非法token
"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
}
else
{
}
else
{
Map
<
String
,
Claim
>
userData
=
jwt
.
getClaims
();
Map
<
String
,
Claim
>
userData
=
jwt
.
getClaims
();
if
(
userData
==
null
)
{
if
(
userData
==
null
)
{
request
.
setAttribute
(
"msg"
,
"
认证信息非法
"
);
request
.
setAttribute
(
"msg"
,
"
非法token
"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/iot_license/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
=
""
;
String
password
=
""
;
if
(!
token
.
equals
(
UserUtils
.
getToken
(
userId
)))
{
request
.
setAttribute
(
"msg"
,
"账户已在别处登录,请重新登录"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
return
;
}
LoginUser
loginUser
=
new
LoginUser
(
userId
,
userName
,
password
);
LoginUser
loginUser
=
new
LoginUser
(
userId
,
userName
,
password
);
Date
curDate
=
new
Date
();
Date
curDate
=
new
Date
();
Date
tokenExp
=
UserUtils
.
getTokenExp
(
userId
);
Date
tokenExp
=
UserUtils
.
getTokenExp
(
userId
);
...
@@ -89,7 +94,7 @@ public class JwtFilter implements Filter {
...
@@ -89,7 +94,7 @@ public class JwtFilter implements Filter {
}
else
{
}
else
{
UserUtils
.
removeToken
(
userId
);
UserUtils
.
removeToken
(
userId
);
UserUtils
.
removeTokenExp
(
userId
);
UserUtils
.
removeTokenExp
(
userId
);
request
.
setAttribute
(
"msg"
,
"token已
失效
"
);
request
.
setAttribute
(
"msg"
,
"token已
过期
"
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/iot_license/fail"
).
forward
(
request
,
response
);
}
}
}
}
...
...
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