Skip to content

Commit d494014

Browse files
committed
More flexible configuration.
1 parent 8395347 commit d494014

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Diff for: config/vufind/SimulatedSSO.ini

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
username = fakeuser1
99

1010
; Map of user attributes to set (corresponding to columns in the user table).
11+
; Comment this out to use defaults, and set "attributes = false" to disable all
12+
; attributes.
1113
attributes[firstname] = Test
1214
attributes[lastname] = User
1315
attributes[email] = "[email protected]"

Diff for: module/VuFind/src/VuFind/Auth/SimulatedSSO.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,15 @@ public function authenticate($request)
9696
throw new AuthException('Simulated failure');
9797
}
9898
$user = $this->getUserTable()->getByUsername($username);
99-
$attribs = array_merge(
100-
$this->defaultAttributes,
101-
$this->simulatedSSOConfig['General']['attributes'] ?? []
102-
);
99+
100+
// Get attribute configuration -- use defaults if no value is set, and use an
101+
// empty array if something invalid was provided.
102+
$attribs = $this->simulatedSSOConfig['General']['attributes']
103+
?? $this->defaultAttributes;
104+
if (!is_array($attribs)) {
105+
$attribs = [];
106+
}
107+
103108
$catPassword = null;
104109
foreach ($attribs as $attribute => $value) {
105110
if ($attribute == 'email') {

0 commit comments

Comments
 (0)