Commit 5e8c4b3d authored by suntao's avatar suntao

权限校验

parent 23c20c85
...@@ -291,7 +291,7 @@ public class UserServiceImpl implements UserService { ...@@ -291,7 +291,7 @@ public class UserServiceImpl implements UserService {
return Result.buildFail("不存在对应的角色"); return Result.buildFail("不存在对应的角色");
} }
Role role = roleRepository.getOne(roleId); Role role = roleRepository.getOne(roleId);
if (!exist.getRole().getId().equals(roleId)) { if (exist.getRole() == null || !exist.getRole().getId().equals(roleId)) {
exist.setRole(role); exist.setRole(role);
} }
if (roleId == 1L) { if (roleId == 1L) {
......
...@@ -69,8 +69,7 @@ public class ApplicationSecurityHandler implements SecurityHandler { ...@@ -69,8 +69,7 @@ public class ApplicationSecurityHandler implements SecurityHandler {
boolean hasPrivilege = principal.isSuperAdministrator(); boolean hasPrivilege = principal.isSuperAdministrator();
List<Role> roleList = getRoleAndParent(principal.getRoles()); List<Role> roleList = getRoleAndParent(principal.getRoles());
hasPrivilege &= CollectionUtils.isEmpty(roleList); hasPrivilege |= CollectionUtils.isNotEmpty(roleList) && roleList.stream().anyMatch(roleItem -> this.checkAuthority(authorityId, roleItem));
hasPrivilege &= roleList.stream().anyMatch(roleItem -> this.checkAuthority(authorityId, roleItem));
if (hasPrivilege) { if (hasPrivilege) {
return new Tuple<>(Boolean.TRUE, null); return new Tuple<>(Boolean.TRUE, null);
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment