Skip to content

Commit

Permalink
Fixed issue: Password complexity for suggested passwords being too low
Browse files Browse the repository at this point in the history
Fixed issue #16423: PasswordRequirement settings saved but not loaded
  • Loading branch information
c-schmitz committed Jan 24, 2022
1 parent f8af58e commit 2ee532e
Showing 1 changed file with 6 additions and 29 deletions.
Expand Up @@ -15,12 +15,12 @@ class PasswordRequirement extends \LimeSurvey\PluginManager\PluginBase
'needsNumber' => array(
'label' => 'Require at least one digit',
'type' => 'checkbox',
'default' => false,
'default' => true,
),
'needsUppercase' => array(
'label' => 'Require at least one uppercase character',
'type' => 'checkbox',
'default' => false,
'default' => true,
),
'needsNonAlphanumeric' => array(
'label' => 'Require at least one special character',
Expand All @@ -30,7 +30,7 @@ class PasswordRequirement extends \LimeSurvey\PluginManager\PluginBase
'minimumSize' => array(
'label' => 'Minimum password length',
'type' => 'int',
'default' => '8',
'default' => 12,
),
];
/**
Expand Down Expand Up @@ -77,9 +77,9 @@ public function createRandomPassword()
$oEvent = $this->getEvent();
$targetSize = $oEvent->get('targetSize', 8);

$targetSize = $targetSize < $this->get('minimumSize', null, null, 8) ? $this->get('minimumSize', null, null, 8) : $targetSize;
$uppercase = $this->get('needsUppercase', null, null, false);
$numeric = $this->get('needsNumber', null, null, false);
$targetSize = $targetSize < $this->get('minimumSize', null, null, 12) ? $this->get('minimumSize', null, null, 12) : $targetSize;
$uppercase = $this->get('needsUppercase', null, null, true);
$numeric = $this->get('needsNumber', null, null, true);
$nonAlpha = $this->get('needsNonAlphanumeric', null, null, false);

$randomPassword = $this->getRandomString($targetSize, $uppercase, $numeric, $nonAlpha);
Expand All @@ -96,29 +96,6 @@ public function createRandomPassword()
public function getPluginSettings($getValues = true)
{
$settings = parent::getPluginSettings();
$settings = [
'needsNumber' => array(
'label' => gT('Require at least one digit'),
'type' => 'checkbox',
'default' => false,
),
'needsUppercase' => array(
'label' => gT('Require at least one uppercase letter'),
'type' => 'checkbox',
'default' => false,
),
'needsNonAlphanumeric' => array(
'label' => gT('Require at least one special character'),
'type' => 'checkbox',
'default' => false,
),
'minimumSize' => array(
'label' => gT('Minimum password length'),
'type' => 'int',
'default' => '8',
'value' => 8
),
];
return $settings;
}

Expand Down

0 comments on commit 2ee532e

Please sign in to comment.