FIX Reset of password can use email like the login.
This commit is contained in:
parent
63982652eb
commit
51383ce6af
@ -238,9 +238,10 @@ class User extends CommonObject
|
||||
* @param string $sid If defined, sid to used for search
|
||||
* @param int $loadpersonalconf 1=also load personal conf of user (in $user->conf->xxx), 0=do not load personal conf.
|
||||
* @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup.
|
||||
* @param int $email If defined, email to used for search
|
||||
* @return int <0 if KO, 0 not found, >0 if OK
|
||||
*/
|
||||
public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1)
|
||||
public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1, $email = '')
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
@ -305,6 +306,10 @@ class User extends CommonObject
|
||||
{
|
||||
$sql.= " AND u.login = '".$this->db->escape($login)."'";
|
||||
}
|
||||
elseif ($email)
|
||||
{
|
||||
$sql.= " AND u.email = '".$this->db->escape($email)."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " AND u.rowid = ".$id;
|
||||
|
||||
@ -45,8 +45,8 @@ $action=GETPOST('action', 'alpha');
|
||||
$mode=$dolibarr_main_authentication;
|
||||
if (! $mode) $mode='http';
|
||||
|
||||
$username = GETPOST('username', 'alpha');
|
||||
$passwordhash = GETPOST('passwordhash', 'alpha');
|
||||
$username = trim(GETPOST('username', 'alpha'));
|
||||
$passwordhash = trim(GETPOST('passwordhash', 'alpha'));
|
||||
$conf->entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : 1);
|
||||
|
||||
// Instantiate hooks of thirdparty module only if not already define
|
||||
@ -104,6 +104,11 @@ if ($action == 'buildnewpassword' && $username)
|
||||
{
|
||||
$edituser = new User($db);
|
||||
$result=$edituser->fetch('', $username, '', 1);
|
||||
if ($result == 0 && preg_match('/@/', $username))
|
||||
{
|
||||
$result=$edituser->fetch('', '', '', 1, -1, $username);
|
||||
}
|
||||
|
||||
if ($result <= 0 && $edituser->error == 'USERNOTFOUND')
|
||||
{
|
||||
$message = '<div class="error">'.$langs->trans("ErrorLoginDoesNotExists", $username).'</div>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user