Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 6f82c8e

Browse files
committed
Fixed the bug from commit bc3ec33 which caused that the updating UES didn't work.
* Problem was caused by rewriting the value of property 'attributes' in the middle of a function, so there weren't any attributes to update.
1 parent 2528dd5 commit 6f82c8e

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
5+
#### Fixed
6+
- Fixed the bug from [bc3ec33] which caused that the updating UES didn't work.
7+
8+
[bc3ec33]:https://github.com/CESNET/perun-simplesamlphp-module/commit/bc3ec33c8f5088f7be712b8e5a0e70f229731648
59

610
## [v3.7.2]
711
#### Fixed

www/updateUes.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$entityBody = file_get_contents('php://input');
1515
$body = json_decode($entityBody, true);
1616

17-
$attributes = $body['attributes'];
17+
$attributesFromIdP = $body['attributes'];
1818
$attrMap = $body['attrMap'];
1919
$attrsToConversion = $body['attrsToConversion'];
2020
$perunUserId = $body['perunUserId'];
@@ -23,30 +23,37 @@
2323

2424
try {
2525
$userExtSource = $adapter->getUserExtSource(
26-
$attributes['sourceIdPEntityID'][0],
27-
$attributes['sourceIdPEppn'][0]
26+
$attributesFromIdP['sourceIdPEntityID'][0],
27+
$attributesFromIdP['sourceIdPEppn'][0]
2828
);
2929
if ($userExtSource === null) {
3030
throw new Exception(
3131
'sspmod_perun_Auth_Process_UpdateUserExtSource: there is no UserExtSource with ExtSource ' .
32-
$attributes['sourceIdPEntityID'][0] . " and Login " .
33-
$attributes['sourceIdPEppn'][0]
32+
$attributesFromIdP['sourceIdPEntityID'][0] . " and Login " .
33+
$attributesFromIdP['sourceIdPEppn'][0]
3434
);
3535
}
3636

37-
$attributes = $adapter->getUserExtSourceAttributes($userExtSource['id'], array_keys($attrMap));
37+
$attributesFromPerunRaw = $adapter->getUserExtSourceAttributes($userExtSource['id'], array_keys($attrMap));
38+
$attributesFromPerun = [];
39+
foreach ($attributesFromPerunRaw as $attributeFromPerunRaw) {
40+
$attributesFromPerun[$attributeFromPerunRaw['friendlyName']] = $attributeFromPerunRaw;
41+
}
3842

39-
if ($attributes === null) {
43+
if ($attributesFromPerun === null) {
4044
throw new Exception(
4145
'sspmod_perun_Auth_Process_UpdateUserExtSource: getting attributes was not successful.'
4246
);
4347
}
4448

4549
$attributesToUpdate = [];
46-
foreach ($attributes as $attribute) {
50+
51+
foreach ($attributesFromPerun as $attribute) {
52+
4753
$attrName = UES_ATTR_NMS . $attribute['friendlyName'];
48-
if (isset($attrMap[$attrName], $attributes[$attrMap[$attrName]])) {
49-
$attr = $attributes[$attrMap[$attrName]];
54+
55+
if (isset($attrMap[$attrName], $attributesFromIdP[$attrMap[$attrName]])) {
56+
$attr = $attributesFromIdP[$attrMap[$attrName]];
5057

5158
if (in_array(UES_ATTR_NMS . $attribute['friendlyName'], $attrsToConversion)) {
5259
$arrayAsString = [''];

0 commit comments

Comments
 (0)