Skip to content

Commit

Permalink
MDL-52610 user: Honour allowaccountssameemail in create_users ws
Browse files Browse the repository at this point in the history
Credit to Dmitriy Kuzevanov.
  • Loading branch information
David Monllao committed Jan 12, 2016
1 parent d16cdbd commit d95dbc0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion user/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ public static function create_users($users) {
// Make sure we validate current user info as handled by current GUI. See user/editadvanced_form.php func validation().
if (!validate_email($user['email'])) {
throw new invalid_parameter_exception('Email address is invalid: '.$user['email']);
} else if ($DB->record_exists('user', array('email' => $user['email'], 'mnethostid' => $user['mnethostid']))) {
} else if (empty($CFG->allowaccountssameemail) &&
$DB->record_exists('user', array('email' => $user['email'], 'mnethostid' => $user['mnethostid']))) {
throw new invalid_parameter_exception('Email address already exists: '.$user['email']);
}
// End of user info validation.
Expand Down

0 comments on commit d95dbc0

Please sign in to comment.