mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00: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
|
* @subpackage security
|
||||||
*/
|
*/
|
||||||
class PasswordValidator extends Object {
|
class PasswordValidator extends Object {
|
||||||
|
|
||||||
private static $character_strength_tests = array(
|
private static $character_strength_tests = array(
|
||||||
'lowercase' => '/[a-z]/',
|
'lowercase' => '/[a-z]/',
|
||||||
'uppercase' => '/[A-Z]/',
|
'uppercase' => '/[A-Z]/',
|
||||||
@ -31,6 +31,7 @@ class PasswordValidator extends Object {
|
|||||||
*/
|
*/
|
||||||
public function minLength($minLength) {
|
public function minLength($minLength) {
|
||||||
$this->minLength = $minLength;
|
$this->minLength = $minLength;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,6 +45,7 @@ class PasswordValidator extends Object {
|
|||||||
public function characterStrength($minScore, $testNames) {
|
public function characterStrength($minScore, $testNames) {
|
||||||
$this->minScore = $minScore;
|
$this->minScore = $minScore;
|
||||||
$this->testNames = $testNames;
|
$this->testNames = $testNames;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,6 +53,7 @@ class PasswordValidator extends Object {
|
|||||||
*/
|
*/
|
||||||
public function checkHistoricalPasswords($count) {
|
public function checkHistoricalPasswords($count) {
|
||||||
$this->historicalPasswordCount = $count;
|
$this->historicalPasswordCount = $count;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +62,7 @@ class PasswordValidator extends Object {
|
|||||||
* @return ValidationResult
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
public function validate($password, $member) {
|
public function validate($password, $member) {
|
||||||
$valid = new ValidationResult();
|
$valid = ValidationResult::create();
|
||||||
|
|
||||||
if($this->minLength) {
|
if($this->minLength) {
|
||||||
if(strlen($password) < $this->minLength) {
|
if(strlen($password) < $this->minLength) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user