Skip to content

Commit 402025e

Browse files
committed
Webservice: Add parameter 'check_email_duplicates' to service 'save_user' to avoid allowing creation of duplicate e-mails - refs BT#21315
1 parent de205bc commit 402025e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

main/inc/lib/webservices/Rest.php

+10
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,16 @@ public function addUser($userParam): array
18961896
$expiration_date = $userParam['expiration_date'];
18971897
}
18981898

1899+
// If check_email_duplicates was set, trigger exception (i.e. do not create) if the e-mail is already used
1900+
if ($userParam['check_email_duplicates']) {
1901+
if (!empty($email)) {
1902+
$userFromEmail = api_get_user_info_from_email($email);
1903+
if (!empty($userFromEmail)) {
1904+
throw new Exception(get_lang('EmailUsedTwice'));
1905+
}
1906+
}
1907+
}
1908+
18991909
// Default language.
19001910
if (empty($language)) {
19011911
$language = api_get_setting('platformLanguage');

0 commit comments

Comments
 (0)