Skip to content

Commit 8a3baf6

Browse files
authored
Allow using nested role config.
1 parent 1518a82 commit 8a3baf6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Auth/AclTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,16 @@ protected function _getUserRoles(ArrayAccess|array $user) {
524524
throw new CakeException('Invalid TinyAuth config, `roleColumn` config missing.');
525525
}
526526

527+
// Check if the roleColumn is a dot notation path
528+
if (str_contains($roleColumn, '.')) {
529+
$role = Hash::get($user, $roleColumn);
530+
if (!$role) {
531+
throw new CakeException(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $roleColumn));
532+
}
533+
534+
return $this->_mapped([$role]);
535+
}
536+
527537
if (!array_key_exists($roleColumn, (array)$user)) {
528538
throw new CakeException(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $this->getConfig('roleColumn')));
529539
}

0 commit comments

Comments
 (0)