Permalink
Browse files

Split email address validation and duplicate check/verification

  • Loading branch information...
aj-gh authored and andygrunwald committed Feb 3, 2019
1 parent a11a220 commit 67c15c8db20d5547b0ce2a30eefaf968242f36e2
@@ -195,6 +195,7 @@
"modules/usrmgr/Functions/CheckOldPW.php",
"modules/usrmgr/Functions/CheckOptGender.php",
"modules/usrmgr/Functions/CheckValidUsername.php",
"modules/usrmgr/Functions/CheckDuplicateAndValidEmail.php",
"modules/usrmgr/Functions/ClanURLLinkUsrMgrSearch.php",
"modules/usrmgr/Functions/ClanURLLinkUsrMgrSearchInc.php",
"modules/usrmgr/Functions/FieldNeeded.php",
@@ -3,8 +3,8 @@
use LanSuite\Validator\Email;
/**
* CheckValidEmail is a callback function for e.g. MasterForm to verify a given email adress against a set of requirements.
* So far it uses a generic (configurable) Validator and checks if the given address is already in use
* CheckValidEmail is a callback function for e.g. MasterForm to verify a given email address against a set of requirements.
* So far it uses a generic (configurable) Validator
*
* @param string $email
* @return bool|mixed|string
@@ -66,17 +66,6 @@ function CheckValidEmail($email)
break;
}
// Compare first and second email entry.
// As only first entry is passed to this function, we have to get the second one from $_POST directly
if (!isset($_POST['email2']) || $email !== $_POST['email2']) {
return t('E-Mail-Adressen stimmen nicht überein. Bitte überprüfe deine Eingabe');
}
// Check if we already have a user with that email address
$row = $db->qry_first('SELECT * FROM %prefix%user WHERE email = %string%', $email);
if ($row){
return t('Diese E-Mail-Adresse ist bereits in Verwendung. Bitte verwende die "Passwort zurücksetzen"-Funktion, um dein Passwort zurück zu setzen');
}
// Check for forbidden trash mail services
$TrashMailDomains = explode("\n", $cfg['mf_forbidden_trashmail_domains']);
foreach ($TrashMailDomains as $key => $val) {
@@ -0,0 +1,30 @@
<?php
/**
* CheckDuplicateAndValidEmail is a callback function to check a given email address for duplicates and
* to perform generic validations via CheckValidEmail.
*
* @param string $email
* @return bool|mixed|string
*/
function CheckDuplicateAndValidEmail($email)
{
global $cfg,$db;
$email = trim($email);
// Compare first and second email entry.
// As only first entry is passed to this function, we have to get the second one from $_POST directly
if (!isset($_POST['email2']) || $email !== $_POST['email2']) {
return t('E-Mail-Adressen stimmen nicht überein. Bitte überprüfe deine Eingabe');
}
// Check if we already have a user with that email address
$row = $db->qry_first('SELECT * FROM %prefix%user WHERE email = %string%', $email);
if ($row){
return t('Diese E-Mail-Adresse ist bereits in Verwendung. Bitte verwende die "Passwort zurücksetzen"-Funktion, um dein Passwort zurück zu setzen');
}
// All checks succeeded; call global email validation routine
return CheckValidEmail($email);
}
@@ -89,7 +89,7 @@
$mf->AddFix('type', 1);
}
$mf->AddField(t('E-Mail'), 'email', '', '', '', 'CheckValidEmail');
$mf->AddField(t('E-Mail'), 'email', '', '', '', 'CheckDuplicateAndValidEmail');
$mf->AddField(t('E-Mail wiederholen'), 'email2', '', '', '');
if (($_GET['action'] != 'change' && $_GET['action'] != 'entrance') || ($_GET['action'] == 'entrance' && !$_GET['userid'])) {
if ($cfg['signon_autopw']) {

0 comments on commit 67c15c8

Please sign in to comment.