|
|
@@ -6,6 +6,7 @@ import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
|
import org.springframework.security.core.userdetails.UserDetails;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -29,9 +30,17 @@ public class LoginUser implements UserDetails {
|
|
|
@Override
|
|
|
@JsonIgnore
|
|
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
|
|
- return roles.stream()
|
|
|
- .map(role -> new SimpleGrantedAuthority("ROLE_" + role))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<GrantedAuthority> authorities = new ArrayList<>();
|
|
|
+ if (roles != null) {
|
|
|
+ roles.stream()
|
|
|
+ .map(role -> new SimpleGrantedAuthority("ROLE_" + role))
|
|
|
+ .forEach(authorities::add);
|
|
|
+ }
|
|
|
+ // employeeType 也作为角色,统一前端菜单和后端接口的权限判断
|
|
|
+ if (employeeType != null && !employeeType.isBlank()) {
|
|
|
+ authorities.add(new SimpleGrantedAuthority("ROLE_" + employeeType));
|
|
|
+ }
|
|
|
+ return authorities;
|
|
|
}
|
|
|
|
|
|
@Override
|