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
5787aa15
Commit
5787aa15
authored
Apr 15, 2019
by
zhengjie
Browse files
update JwtTokenUtil and JwtPermissionService
parent
d6af3c15
Changes
3
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtPermissionService.java
View file @
5787aa15
...
...
@@ -34,11 +34,8 @@ public class JwtPermissionService {
Set
<
Role
>
roles
=
roleRepository
.
findByUsers_Id
(
user
.
getId
());
Set
<
Permission
>
permissions
=
new
HashSet
<>();
for
(
Role
role
:
roles
)
{
Set
<
Role
>
roleSet
=
new
HashSet
<>();
roleSet
.
add
(
role
);
permissions
.
addAll
(
permissionRepository
.
findByRoles_Id
(
role
.
getId
()));
}
permissions
.
addAll
(
permissionRepository
.
findByRoles
(
roles
));
return
permissions
.
stream
()
.
map
(
permission
->
new
SimpleGrantedAuthority
(
permission
.
getName
()))
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/utils/JwtTokenUtil.java
View file @
5787aa15
...
...
@@ -108,7 +108,7 @@ public class JwtTokenUtil implements Serializable {
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
// final Date expiration = getExpirationDateFromToken(token);
// 如果token存在,且token创建日期 > 最后修改密码的日期 则代表token有效
return
(
isTokenExpired
(
token
)
return
(
!
isTokenExpired
(
token
)
&&
!
isCreatedBeforeLastPasswordReset
(
created
,
user
.
getLastPasswordResetDate
())
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java
View file @
5787aa15
...
...
@@ -30,4 +30,6 @@ public interface PermissionRepository extends JpaRepository<Permission, Long>, J
List
<
Permission
>
findByPid
(
long
pid
);
Set
<
Permission
>
findByRoles_Id
(
Long
id
);
Set
<
Permission
>
findByRoles
(
Set
<
Role
>
roles
);
}
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