Skip to content

Commit dbf6658

Browse files
renothingfguillot
authored andcommitted
fix getKey error when userinfo with nested structure
for example some OAuth2 provider provide multiple emails like this: ``` { "_id": "aobEdbYhXfu5hkeqG", "name": "Example User", "emails": [ { "address": "example1@example.com", "primary": true }, { "address": "example2@example.com", "primary": false } ], "status": "offline", "statusConnection": "offline", "username": "example", "utcOffset": 0, ...... ``` we need get email address for email map in kanboard. this patch use `.` as separator to get value from nested structure. in this example we can use `emails.0.address` as key name to get first email address.
1 parent a8941d5 commit dbf6658

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

User/GenericOAuth2UserProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ public function validateDomainRestriction(array $profile, $domains)
219219

220220
protected function getKey($key)
221221
{
222-
$key = $this->configModel->get($key);
223-
return ! empty($key) && isset($this->userData[$key]) ? $this->userData[$key] : '';
222+
$key = explode('.', $this->configModel->get($key));
223+
$value = $this->userData;
224+
foreach ($key as $k) {
225+
$value = $value[$k];
226+
}
227+
return ! empty($key) && isset($value) ? $value : '';
224228
}
225229
}

0 commit comments

Comments
 (0)