FIX: #12908 User login with credentials from self-subscription form fails
This commit is contained in:
parent
5dcd5e5b87
commit
9f7b51938f
@ -641,7 +641,7 @@ class Adherent extends CommonObject
|
|||||||
$isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1;
|
$isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1;
|
||||||
|
|
||||||
// If password to set differs from the one found into database
|
// If password to set differs from the one found into database
|
||||||
$result=$this->setPassword($user, $this->pass, $this->pass_indatabase_crypted, $isencrypted, $notrigger, $nosyncuserpass);
|
$result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass);
|
||||||
if (! $nbrowsaffected) $nbrowsaffected++;
|
if (! $nbrowsaffected) $nbrowsaffected++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -964,9 +964,10 @@ class Adherent extends CommonObject
|
|||||||
* @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut)
|
* @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut)
|
||||||
* @param int $notrigger 1=Ne declenche pas les triggers
|
* @param int $notrigger 1=Ne declenche pas les triggers
|
||||||
* @param int $nosyncuser Do not synchronize linked user
|
* @param int $nosyncuser Do not synchronize linked user
|
||||||
|
* @param int $alreadyencrypted 1 = password is already encrypted (0 by default)
|
||||||
* @return string If OK return clear password, 0 if no change, < 0 if error
|
* @return string If OK return clear password, 0 if no change, < 0 if error
|
||||||
*/
|
*/
|
||||||
public function setPassword($user, $password = '', $password_indatabase_crypted = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0)
|
public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0, $alreadyencrypted = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
@ -974,24 +975,23 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted);
|
dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted);
|
||||||
|
|
||||||
// If password_crypted not provided, try crypt password provided
|
|
||||||
if(!$password_indatabase_crypted)
|
|
||||||
{
|
|
||||||
// If new password not provided, we generate one
|
// If new password not provided, we generate one
|
||||||
if (!$password)
|
if (! $password)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
$password=getRandomPassword(false);
|
$password=getRandomPassword(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crypt password
|
// Crypt password
|
||||||
$password_crypted = dol_hash($password);
|
if ($alreadyencrypted != 1) $password_crypted = dol_hash($password);
|
||||||
|
else $password_crypted = $password;
|
||||||
|
|
||||||
} else {
|
$password_indatabase = '';
|
||||||
$password_crypted = $password_indatabase_crypted;
|
if (! $isencrypted)
|
||||||
|
{
|
||||||
|
$password_indatabase = $password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Mise a jour
|
// Mise a jour
|
||||||
@ -1032,7 +1032,7 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$result=$luser->setPassword($user, $this->pass, $this->pass_indatabase_crypted, 0, 0, 1);
|
$result=$luser->setPassword($user, $this->pass, 0, 0, 1, 1);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$luser->error;
|
$this->error=$luser->error;
|
||||||
|
|||||||
@ -1418,7 +1418,9 @@ class User extends CommonObject
|
|||||||
$result = $this->create($user);
|
$result = $this->create($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$newpass = $this->setPassword($user, $this->pass, $this->pass_indatabase_crypted);
|
if(!$this->pass && $this->pass_indatabase_crypted) $newpass = $this->setPassword($user, $this->pass_indatabase_crypted, 0, 0, 0, 1);
|
||||||
|
else $newpass = $this->setPassword($user, $this->pass);
|
||||||
|
|
||||||
if (is_numeric($newpass) && $newpass < 0) $result = -2;
|
if (is_numeric($newpass) && $newpass < 0) $result = -2;
|
||||||
|
|
||||||
if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty
|
if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty
|
||||||
@ -1853,9 +1855,10 @@ class User extends CommonObject
|
|||||||
* @param int $changelater 1=Change password only after clicking on confirm email
|
* @param int $changelater 1=Change password only after clicking on confirm email
|
||||||
* @param int $notrigger 1=Does not launch triggers
|
* @param int $notrigger 1=Does not launch triggers
|
||||||
* @param int $nosyncmember Do not synchronize linked member
|
* @param int $nosyncmember Do not synchronize linked member
|
||||||
|
* @param int $alreadyencrypted 1 = password is already encrypted (0 by default)
|
||||||
* @return string If OK return clear password, 0 if no change, < 0 if error
|
* @return string If OK return clear password, 0 if no change, < 0 if error
|
||||||
*/
|
*/
|
||||||
public function setPassword($user, $password = '', $password_indatabase_crypted = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0)
|
public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $alreadyencrypted = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
@ -1864,9 +1867,6 @@ class User extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG);
|
dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG);
|
||||||
|
|
||||||
// If password_crypted not provided, try crypt password provided
|
|
||||||
if(!$password_indatabase_crypted)
|
|
||||||
{
|
|
||||||
// If new password not provided, we generate one
|
// If new password not provided, we generate one
|
||||||
if (!$password)
|
if (!$password)
|
||||||
{
|
{
|
||||||
@ -1874,11 +1874,8 @@ class User extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crypt password
|
// Crypt password
|
||||||
$password_crypted = dol_hash($password);
|
if ($alreadyencrypted != 1) $password_crypted = dol_hash($password);
|
||||||
} else {
|
else $password_crypted = $password;
|
||||||
$password_crypted = $password_indatabase_crypted;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Mise a jour
|
// Mise a jour
|
||||||
@ -1922,7 +1919,11 @@ class User extends CommonObject
|
|||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$result = $adh->setPassword($user, $this->pass, $this->pass_indatabase_crypted, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent
|
|
||||||
|
if ($alreadyencrypted != 1) $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent
|
||||||
|
else $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1, 0, 1); // Dont encrypt the password cause is already encrypted
|
||||||
|
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error = $adh->error;
|
$this->error = $adh->error;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user