Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix old typo in length
Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 authored and backportbot-nextcloud[bot] committed May 12, 2022
commit 2ab7d2d21a0b8347b6394a5b8b93d57779459ae4
12 changes: 6 additions & 6 deletions lib/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function generate(): string {
// 8 minimum so we don't generate too short passwords
$minLength = 8;
}
$lenght = $minLength;
$length = $minLength;

$password = '';
$chars = '';
Expand All @@ -67,27 +67,27 @@ public function generate(): string {
if ($this->config->getEnforceUpperLowerCase()) {
$password .= $this->random->generate(1, ISecureRandom::CHAR_UPPER);
$password .= $this->random->generate(1, ISecureRandom::CHAR_LOWER);
$lenght -= 2;
$length -= 2;
$chars .= ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER;
}

if ($this->config->getEnforceNumericCharacters()) {
$password .= $this->random->generate(1, ISecureRandom::CHAR_DIGITS);
$lenght -= 1;
$length -= 1;
$chars .= ISecureRandom::CHAR_DIGITS;
}

if ($this->config->getEnforceSpecialCharacters()) {
$password .= $this->random->generate(1, ISecureRandom::CHAR_SYMBOLS);
$lenght -= 1;
$length -= 1;
$chars .= ISecureRandom::CHAR_SYMBOLS;
}

if ($chars === '') {
$chars = ISecureRandom::CHAR_HUMAN_READABLE;
}

$password .= $chars = $this->random->generate($lenght, $chars);
$password .= $chars = $this->random->generate($length, $chars);

try {
$this->validator->validate($password);
Expand All @@ -104,7 +104,7 @@ public function generate(): string {
* Invalid so lets go for another round
* Reset the length so we don't run below zero
*/
$lenght = $minLength;
$length = $minLength;
}
}

Expand Down