2
2
3
3
import com .fasterxml .jackson .core .type .TypeReference ;
4
4
import com .fasterxml .jackson .databind .ObjectMapper ;
5
- import io .home .pi .domain .Grp ;
6
- import io .home .pi .domain .GrpAuthority ;
5
+ import io .home .pi .domain .GrpAuth ;
7
6
import io .home .pi .domain .User ;
8
7
import io .home .pi .service .UserService ;
9
8
import org .slf4j .Logger ;
@@ -67,15 +66,14 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx
67
66
private List <GrantedAuthority > getGrantedAuthorities (User user ) {
68
67
List <GrantedAuthority > authorities = new ArrayList <>();
69
68
try {
70
- List <GrpAuthority > groupAuthorities = new ArrayList <>();
69
+ List <GrpAuth > groupAuthorities = new ArrayList <>();
70
+
71
+ groupAuthorities .add (user .getTeam ().getGrpAuth ());
71
72
72
- for (Grp grp : user .getGrps ()) {
73
- groupAuthorities .add (grp .getGrpAuthority ());
74
- }
75
73
76
- for (GrpAuthority userAuth : decodeHashMap ( groupAuthorities ) ) {
77
- LOGGER .info ("User Authority : " + userAuth .toString ());
78
- authorities .add (new SimpleGrantedAuthority (USER_ROLE_PREFIX + userAuth .getAuthorities ()));
74
+ for (GrpAuth userAuth : groupAuthorities ) {
75
+ LOGGER .info ("User Auth : " + userAuth .toString ());
76
+ authorities .add (new SimpleGrantedAuthority (USER_ROLE_PREFIX + userAuth .getAuthorities (). iterator (). next (). getLevel () ));
79
77
}
80
78
} catch (Exception e ) {
81
79
LOGGER .error (e .getMessage (), e );
@@ -90,13 +88,13 @@ private List<GrantedAuthority> getGrantedAuthorities(User user) {
90
88
}
91
89
92
90
93
- private List <GrpAuthority > decodeHashMap (List <GrpAuthority > authorities ) {
94
- List <GrpAuthority > authoritiesArrayList = new ArrayList <>();
91
+ private List <GrpAuth > decodeHashMap (List <GrpAuth > authorities ) {
92
+ List <GrpAuth > authoritiesArrayList = new ArrayList <>();
95
93
ObjectMapper mapper = new ObjectMapper ();
96
94
97
95
try {
98
- List <GrpAuthority > groupAuthorities = mapper .convertValue (authorities ,
99
- new TypeReference <List <GrpAuthority >>() {
96
+ List <GrpAuth > groupAuthorities = mapper .convertValue (authorities ,
97
+ new TypeReference <List <GrpAuth >>() {
100
98
});
101
99
102
100
authoritiesArrayList .addAll (groupAuthorities );
0 commit comments