Skip to content

Commit

Permalink
Users: Allow empty email, if email is not required in registration
Browse files Browse the repository at this point in the history
BT#17731
  • Loading branch information
jmontoyaa committed Sep 21, 2020
1 parent 20be1d0 commit 6563e42
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions main/inc/lib/usermanager.lib.php
Expand Up @@ -224,12 +224,24 @@ public static function create_user(
$hook->notifyCreateUser(HOOK_EVENT_TYPE_PRE);
}

if (false === api_valid_email($email)) {
Display::addFlash(
Display::return_message(get_lang('PleaseEnterValidEmail').' - '.$email, 'warning')
);
if ('true' === api_get_setting('registration', 'email')) {
// Force email validation.
if (false === api_valid_email($email)) {
Display::addFlash(
Display::return_message(get_lang('PleaseEnterValidEmail').' - '.$email, 'warning')
);

return false;
}
} else {
// Allow empty email. If email is set, check if is valid.
if (!empty($email) && false === api_valid_email($email)) {
Display::addFlash(
Display::return_message(get_lang('PleaseEnterValidEmail').' - '.$email, 'warning')
);

return false;
return false;
}
}

if ('true' === api_get_setting('login_is_email')) {
Expand Down Expand Up @@ -7143,4 +7155,9 @@ private static function getGravatar(

return $url;
}

private static function checkEmail($email)
{

}
}

0 comments on commit 6563e42

Please sign in to comment.