chg: [user] Relaxed email validation rule

pull/7502/head
mokaddem 2021-06-16 14:03:24 +02:00
parent 7226b1371f
commit 6f85e3e39d
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 13 additions and 6 deletions

View File

@ -65,13 +65,10 @@ class User extends AppModel
),
),
'email' => array(
'email' => array(
'rule' => array('email'),
'message' => 'Please enter a valid email address.',
//'allowEmpty' => false,
'emailValidation' => array(
'rule' => array('validateEmail'),
'message' => 'Please nter a valid email address.',
'required' => true,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'unique' => array(
'rule' => 'isUnique',
@ -386,6 +383,16 @@ class User extends AppModel
return true;
}
public function validateEmail($check)
{
$localPartReg = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@';
$domainReg = '[a-z0-9_\-\.]+';
$fullReg = sprintf('/^%s%s$/ui', $localPartReg, $domainReg);
$check = array_values($check);
$check = $check[0];
return preg_match($fullReg, $check, $matches) ? true : false;
}
/*
default password:
6 characters minimum