...
|
...
|
@@ -15,6 +15,7 @@ package org.thingsboard.server.service.security.model; |
15
|
15
|
|
16
|
16
|
import lombok.Getter;
|
17
|
17
|
import lombok.Setter;
|
|
18
|
+import org.apache.commons.lang3.StringUtils;
|
18
|
19
|
import org.springframework.security.core.GrantedAuthority;
|
19
|
20
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
20
|
21
|
import org.thingsboard.server.common.data.User;
|
...
|
...
|
@@ -71,14 +72,12 @@ public class SecurityUser extends User { |
71
|
72
|
.map(RoleEnum::name)
|
72
|
73
|
.collect(Collectors.toSet());
|
73
|
74
|
this.ptSysadmin =
|
74
|
|
- this.roles.stream()
|
75
|
|
- .anyMatch(role -> role.equals(RoleEnum.ROLE_SYS_ADMIN.name()));
|
|
75
|
+ this.roles.stream().anyMatch(role -> role.equals(RoleEnum.SYS_ADMIN.name()));
|
76
|
76
|
this.ptTenantAdmin =
|
77
|
|
- this.roles.stream()
|
78
|
|
- .anyMatch(role -> role.equals(RoleEnum.ROLE_TENANT_ADMIN.name()));
|
|
77
|
+ this.roles.stream().anyMatch(role -> role.equals(RoleEnum.TENANT_ADMIN.name()));
|
79
|
78
|
this.ptmAdmin =
|
80
|
79
|
this.roles.stream()
|
81
|
|
- .anyMatch(role -> role.equals(RoleEnum.ROLE_PLATFORM_ADMIN.name()));
|
|
80
|
+ .anyMatch(role -> role.equals(RoleEnum.PLATFORM_ADMIN.name()));
|
82
|
81
|
return roleDTOS;
|
83
|
82
|
});
|
84
|
83
|
}
|
...
|
...
|
@@ -86,10 +85,15 @@ public class SecurityUser extends User { |
86
|
85
|
|
87
|
86
|
public Collection<GrantedAuthority> getAuthorities() {
|
88
|
87
|
if (authorities == null) {
|
89
|
|
- authorities =
|
90
|
|
- Stream.of(SecurityUser.this.getAuthority())
|
91
|
|
- .map(authority -> new SimpleGrantedAuthority(authority.name()))
|
92
|
|
- .collect(Collectors.toList());
|
|
88
|
+ if (roles == null || roles.isEmpty()) {
|
|
89
|
+ authorities =
|
|
90
|
+ Stream.of(SecurityUser.this.getAuthority())
|
|
91
|
+ .map(authority -> new SimpleGrantedAuthority(authority.name()))
|
|
92
|
+ .collect(Collectors.toList());
|
|
93
|
+ } else {
|
|
94
|
+ authorities =
|
|
95
|
+ this.roles.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());
|
|
96
|
+ }
|
93
|
97
|
}
|
94
|
98
|
return authorities;
|
95
|
99
|
}
|
...
|
...
|
|