Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
V
volunteer_service
Project
Project
Details
Activity
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
licc
volunteer_service
Commits
38e338fb
Commit
38e338fb
authored
Apr 11, 2021
by
xc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shiro限定并发登录人数
parent
5e9fb667
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
21 deletions
+16
-21
KickoutSessionControlFilter.java
...ergy/service/shir/filter/KickoutSessionControlFilter.java
+16
-21
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/shir/filter/KickoutSessionControlFilter.java
View file @
38e338fb
...
...
@@ -72,7 +72,22 @@ public class KickoutSessionControlFilter extends AccessControlFilter{
HttpServletResponse
httpServletResponse
=
(
HttpServletResponse
)
response
;
// 登录超时
Object
object
=
SecurityUtils
.
getSubject
().
getPrincipal
();
Integer
userId
=
getUserId
(
object
);
Integer
userId
=
null
;
try
{
//客户端
User
user
=
(
User
)
object
;
userId
=
user
.
getId
();
}
catch
(
Exception
e
)
{
try
{
//管理端
AccountInfo
accountInfo
=
(
AccountInfo
)
object
;
userId
=
accountInfo
.
getId
();
}
catch
(
Exception
en
)
{
//员工端
Staff
staff
=
(
Staff
)
object
;
userId
=
staff
.
getId
();
}
}
Long
SessionTime
=
(
Long
)
redisTemplate
.
opsForValue
().
get
(
"shiroSessionTime:"
+
userId
);
Long
loginTime
=
new
Date
().
getTime
()-
SessionTime
;
Boolean
loginOutTime
=
(
new
Date
().
getTime
()-
SessionTime
)
>=
(
EXPIRE_TIME
*
1000
);
...
...
@@ -198,26 +213,6 @@ public class KickoutSessionControlFilter extends AccessControlFilter{
}
}
private
Integer
getUserId
(
Object
object
){
Integer
userId
=
null
;
try
{
//客户端
User
user
=
(
User
)
object
;
userId
=
user
.
getId
();
}
catch
(
Exception
e
)
{
try
{
//管理端
AccountInfo
accountInfo
=
(
AccountInfo
)
object
;
userId
=
accountInfo
.
getId
();
}
catch
(
Exception
en
)
{
//员工端
Staff
staff
=
(
Staff
)
object
;
userId
=
staff
.
getId
();
}
}
return
userId
;
}
private
void
setHeader
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//跨域的header设置
response
.
setHeader
(
"Access-control-Allow-Origin"
,
request
.
getHeader
(
"Origin"
));
...
...
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