Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
a90bfac2
Commit
a90bfac2
authored
Dec 24, 2020
by
zhengjie
Browse files
[代码优化](v2.6):禁用用户后踢出用户Bug修复
close
https://github.com/elunez/eladmin/issues/551
parent
1556f133
Changes
4
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java
View file @
a90bfac2
...
@@ -179,11 +179,12 @@ public class OnlineUserService {
...
@@ -179,11 +179,12 @@ public class OnlineUserService {
* @param username /
* @param username /
*/
*/
@Async
@Async
public
void
kickOutForUsername
(
String
username
)
{
public
void
kickOutForUsername
(
String
username
)
throws
Exception
{
List
<
OnlineUserDto
>
onlineUsers
=
getAll
(
username
);
List
<
OnlineUserDto
>
onlineUsers
=
getAll
(
username
);
for
(
OnlineUserDto
onlineUser
:
onlineUsers
)
{
for
(
OnlineUserDto
onlineUser
:
onlineUsers
)
{
if
(
onlineUser
.
getUserName
().
equals
(
username
))
{
if
(
onlineUser
.
getUserName
().
equals
(
username
))
{
kickOut
(
onlineUser
.
getKey
());
String
token
=
EncryptUtils
.
desDecrypt
(
onlineUser
.
getKey
());
kickOut
(
token
);
}
}
}
}
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
a90bfac2
...
@@ -114,7 +114,7 @@ public class UserController {
...
@@ -114,7 +114,7 @@ public class UserController {
@ApiOperation
(
"修改用户"
)
@ApiOperation
(
"修改用户"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('user:edit')"
)
@PreAuthorize
(
"@el.check('user:edit')"
)
public
ResponseEntity
<
Object
>
update
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
)
throws
Exception
{
checkLevel
(
resources
);
checkLevel
(
resources
);
userService
.
update
(
resources
);
userService
.
update
(
resources
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java
View file @
a90bfac2
...
@@ -49,7 +49,7 @@ public interface UserService {
...
@@ -49,7 +49,7 @@ public interface UserService {
* 编辑用户
* 编辑用户
* @param resources /
* @param resources /
*/
*/
void
update
(
User
resources
);
void
update
(
User
resources
)
throws
Exception
;
/**
/**
* 删除用户
* 删除用户
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
a90bfac2
...
@@ -98,7 +98,7 @@ public class UserServiceImpl implements UserService {
...
@@ -98,7 +98,7 @@ public class UserServiceImpl implements UserService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
User
resources
)
{
public
void
update
(
User
resources
)
throws
Exception
{
User
user
=
userRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
User:
:
new
);
User
user
=
userRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
User:
:
new
);
ValidationUtil
.
isNull
(
user
.
getId
(),
"User"
,
"id"
,
resources
.
getId
());
ValidationUtil
.
isNull
(
user
.
getId
(),
"User"
,
"id"
,
resources
.
getId
());
User
user1
=
userRepository
.
findByUsername
(
resources
.
getUsername
());
User
user1
=
userRepository
.
findByUsername
(
resources
.
getUsername
());
...
...
Write
Preview
Supports
Markdown
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