mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2574 from dhensby/patch-1
Allowing chaining on `PasswordValidator`
This commit is contained in:
commit
42fa4d6005
@ -16,7 +16,7 @@
|
||||
* @subpackage security
|
||||
*/
|
||||
class PasswordValidator extends Object {
|
||||
|
||||
|
||||
private static $character_strength_tests = array(
|
||||
'lowercase' => '/[a-z]/',
|
||||
'uppercase' => '/[A-Z]/',
|
||||
@ -31,6 +31,7 @@ class PasswordValidator extends Object {
|
||||
*/
|
||||
public function minLength($minLength) {
|
||||
$this->minLength = $minLength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,6 +45,7 @@ class PasswordValidator extends Object {
|
||||
public function characterStrength($minScore, $testNames) {
|
||||
$this->minScore = $minScore;
|
||||
$this->testNames = $testNames;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,6 +53,7 @@ class PasswordValidator extends Object {
|
||||
*/
|
||||
public function checkHistoricalPasswords($count) {
|
||||
$this->historicalPasswordCount = $count;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +62,7 @@ class PasswordValidator extends Object {
|
||||
* @return ValidationResult
|
||||
*/
|
||||
public function validate($password, $member) {
|
||||
$valid = new ValidationResult();
|
||||
$valid = ValidationResult::create();
|
||||
|
||||
if($this->minLength) {
|
||||
if(strlen($password) < $this->minLength) {
|
||||
|
Loading…
Reference in New Issue
Block a user