Skip to content
Snippets Groups Projects
Commit 93911a38 authored by Dominik František Bučík's avatar Dominik František Bučík
Browse files

chore: merge branch 'find_user_by_email' into 'main'

feat: :guitar: RPC method - find user by email

See merge request perun-proxy-aai/simplesamlphp/simplesamlphp-module-perun!313
parents 10c25680 5095ca4a
No related branches found
No related tags found
1 merge request!313feat: 🎸 RPC method - find user by email
Pipeline #320956 passed with warnings
......@@ -119,6 +119,41 @@ class AdapterRpc extends Adapter
return $this->getPerunUser($idpEntityId, $uids);
}
public function getPerunUserByEmail($emailAttrUrn, $emailValue)
{
$user = null;
$users = $this->connector->get('usersManager', 'getUsersByAttributeValue', [
'attributeName' => $emailAttrUrn,
'attributeValue' => $emailValue,
]);
if (count($users) > 1) {
throw new Exception('Multiple users with email ' . $emailValue . ' found');
} elseif (count($users) === 0) {
throw new Exception('No users with email ' . $emailValue . ' found');
} else {
$user = $users[0];
$name = '';
if (!empty($user['titleBefore'])) {
$name .= $user['titleBefore'] . ' ';
}
if (!empty($user['firstName'])) {
$name .= $user['firstName'] . ' ';
}
if (!empty($user['middleName'])) {
$name .= $user['middleName'] . ' ';
}
if (!empty($user['lastName'])) {
$name .= $user['lastName'];
}
if (!empty($user['titleAfter'])) {
$name .= ' ' . $user['titleAfter'];
}
return new User($user['id'], $name);
}
}
public function getMemberGroups($user, $vo)
{
try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment