Fixes potential for generated password to not meet own validation requirements

This commit is contained in:
Dane Everitt 2016-12-01 19:16:40 -05:00
parent 90460bef43
commit ed5b7559ec
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 13 additions and 1 deletions

View file

@ -62,7 +62,16 @@ class IndexController extends Controller
public function getPassword(Request $request, $length = 16)
{
$length = ($length < 8) ? 8 : $length;
return str_random($length);
$returnable = false;
while (!$returnable) {
$generated = str_random($length);
if (preg_match('/[A-Z]+[a-z]+[0-9]+/', $generated)) {
$returnable = true;
}
}
return $generated;
}
}