File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -31,10 +31,16 @@ public function __invoke(array $records)
3131 {
3232 $ records ['extra ' ]['token ' ] = null ;
3333 if (null !== $ token = $ this ->tokenStorage ->getToken ()) {
34+ if (method_exists ($ token , 'getRoleNames ' )) {
35+ $ roles = $ token ->getRoleNames ();
36+ } else {
37+ $ roles = array_map (function ($ role ) { return $ role ->getRole (); }, $ token ->getRoles (false ));
38+ }
39+
3440 $ records ['extra ' ]['token ' ] = [
3541 'username ' => $ token ->getUsername (),
3642 'authenticated ' => $ token ->isAuthenticated (),
37- 'roles ' => array_map ( function ( $ role ) { return $ role -> getRole (); }, $ token -> getRoles ()) ,
43+ 'roles ' => $ roles ,
3844 ];
3945 }
4046
Original file line number Diff line number Diff line change @@ -36,7 +36,6 @@ public function testProcessor()
3636 $ this ->assertArrayHasKey ('token ' , $ record ['extra ' ]);
3737 $ this ->assertEquals ($ token ->getUsername (), $ record ['extra ' ]['token ' ]['username ' ]);
3838 $ this ->assertEquals ($ token ->isAuthenticated (), $ record ['extra ' ]['token ' ]['authenticated ' ]);
39- $ roles = array_map (function ($ role ) { return $ role ->getRole (); }, $ token ->getRoles ());
40- $ this ->assertEquals ($ roles , $ record ['extra ' ]['token ' ]['roles ' ]);
39+ $ this ->assertEquals (['ROLE_USER ' ], $ record ['extra ' ]['token ' ]['roles ' ]);
4140 }
4241}
You can’t perform that action at this time.
0 commit comments