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

Commit ba41ea6

Browse files
committed
Fixed getting attributes from Perun in partial mode in PerunAttributes.php
* Allow to store one source attribute to more destination attributes * Don't call method for getting attributes with empty attributes list
1 parent 1e1f564 commit ba41ea6

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

CHANGELOG.md

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

44
## [Unreleased]
5+
#### Fixed
6+
- Fixed getting attributes from Perun in partial mode
7+
- Allow to store one source attribute to more destination attributes
58

69
## [v4.0.1]
710
#### Fixed

lib/Auth/Process/PerunAttributes.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,28 @@ public function process(&$request)
8181
} elseif ($this->mode === self::MODE_PARTIAL) {
8282
// Check if attribute has some value
8383
foreach ($this->attrMap as $attrName => $attrValue) {
84-
if (isset($request['Attributes'][$attrValue])) {
85-
$attr = $request['Attributes'][$attrValue];
86-
if (empty($attr)) {
84+
if (is_array($attrValue)) {
85+
$attrValueList = $attrValue;
86+
} else{
87+
$attrValueList = [$attrValue];
88+
}
89+
foreach ($attrValueList as $item) {
90+
if (isset($request['Attributes'][$item])) {
91+
$attr = $request['Attributes'][$item];
92+
if (empty($attr)) {
93+
array_push($attributes, $attrName);
94+
}
95+
} else {
8796
array_push($attributes, $attrName);
8897
}
89-
} else {
90-
array_push($attributes, $attrName);
9198
}
9299
}
93100
}
94101

102+
if (empty($attributes)) {
103+
return;
104+
}
105+
$attributes = array_unique($attributes);
95106
$attrs = $this->adapter->getUserAttributesValues($user, $attributes);
96107

97108
foreach ($attrs as $attrName => $attrValue) {

0 commit comments

Comments
 (0)