@@ -40,14 +40,27 @@ public function authenticate(&$state)
4040 exit ;
4141 }
4242
43- $ userAttributes = [
44- 'email ' => $ userInfo ->data ->attributes ->email ,
45- 'employee-id ' => $ userInfo ->data ->attributes ->{'employee-id ' },
46- 'document ' => $ userInfo ->data ->attributes ->{'document ' },
47- 'document-type ' => $ userInfo ->data ->attributes ->{'document-type ' },
48- 'name ' => $ userInfo ->data ->attributes ->{'name ' },
49- 'last-name ' => $ userInfo ->data ->attributes ->{'last-name ' },
50- ];
43+ $ userAttributes = [];
44+ $ userInfoAttribues = $ userInfo ->data ->attributes ;
45+ $ customAttributes = $ state ['SPMetadata ' ]['CustomAttributes ' ];
46+
47+ if (is_array ($ customAttributes ) && !empty ($ customAttributes )) {
48+ foreach ($ customAttributes as $ customAttributeKey => $ customAttributeValue ) {
49+ $ userAttributes [$ customAttributeValue ] = isset ($ userInfoAttribues ->$ customAttributeKey )
50+ ? $ userInfoAttribues ->$ customAttributeKey :
51+ '' ;
52+ }
53+ } else {
54+ $ userAttributes = [
55+ 'email ' => $ userInfoAttribues ->email ,
56+ 'employee-id ' => $ userInfoAttribues ->{'employee-id ' },
57+ 'document ' => $ userInfoAttribues ->{'document ' },
58+ 'document-type ' => $ userInfoAttribues ->{'document-type ' },
59+ 'name ' => $ userInfoAttribues ->{'name ' },
60+ 'last-name ' => $ userInfoAttribues ->{'last-name ' },
61+ ];
62+ }
63+
5164 $ state ['Attributes ' ] = SimpleSAML_Utilities::parseAttributes ($ userAttributes );
5265
5366 SimpleSAML_Auth_Source::completeAuth ($ state );
0 commit comments