FIX if password doesnt match rule it created a user without password

This commit is contained in:
Quentin VIAL-GOUTEYRON 2022-06-01 11:33:15 +02:00
parent c8ff7ff02a
commit 682da1fabe

View File

@ -333,9 +333,16 @@ if (empty($reshook)) {
$id = $object->create($user); $id = $object->create($user);
if ($id > 0) { if ($id > 0) {
$resPass = '';
if (GETPOST('password', 'none')) { if (GETPOST('password', 'none')) {
$object->setPassword($user, GETPOST('password', 'none')); $resPass = $object->setPassword($user, GETPOST('password', 'none'));
} }
if($resPass < 0) {
$langs->load("errors");
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action = "create"; // Go back to create page
} else {
if(! empty($conf->categorie->enabled)) { if(! empty($conf->categorie->enabled)) {
// Categories association // Categories association
$usercats = GETPOST('usercats', 'array'); $usercats = GETPOST('usercats', 'array');
@ -345,6 +352,7 @@ if (empty($reshook)) {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id);
exit; exit;
}
} else { } else {
$langs->load("errors"); $langs->load("errors");
$db->rollback(); $db->rollback();