Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into 10.0

This commit is contained in:
Laurent Destailleur 2019-10-07 20:52:39 +02:00
commit 51be0fad99
2 changed files with 18 additions and 16 deletions

View File

@ -174,15 +174,15 @@ if ($action == 'maj_pattern')
$explodePattern = explode(';', $pattern);
$patternInError = false;
if($explodePattern[0] < 1 || $explodePattern[4] < 0){
if ($explodePattern[0] < 1 || $explodePattern[4] < 0) {
$patternInError = true;
}
if($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]){
if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) {
$patternInError = true;
}
if(!$patternInError){
if (!$patternInError) {
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity);
header("Location: security.php");
exit;

View File

@ -187,31 +187,31 @@ class modGeneratePassPerso extends ModeleGenPassword
$spe = str_split($this->Spe);
if (count(array_intersect($password_a, $maj)) < $this->NbMaj) {
return 0;
return false;
}
if (count(array_intersect($password_a, $num)) < $this->NbNum) {
return 0;
return false;
}
if (count(array_intersect($password_a, $spe)) < $this->NbSpe) {
return 0;
return false;
}
if (!$this->consecutiveInterationSameCharacter($password)) {
return 0;
return false;
}
return 1;
return true;
}
/**
* Consecutive iterations of the same character
* Check the consecutive iterations of the same character. Return false if the number doesn't match the maximum consecutive value allowed.
*
* @param string $password Password to check
* @return int 0 if KO, >0 if OK
* @return bool
*/
public function consecutiveInterationSameCharacter($password)
private function consecutiveInterationSameCharacter($password)
{
$last = "";
@ -224,14 +224,16 @@ class modGeneratePassPerso extends ModeleGenPassword
if($c != $last) {
$last = $c;
$count = 0;
} else {
$count++;
continue;
}
if ($count >= $this->NbRepeat) {
return 0;
$count++;
if ($count > $this->NbRepeat) {
return false;
}
}
return 1;
return true;
}
}