Exemplo n.º 1
0
 /**
  * Set password rule based on our setting value (Force Strong Password).
  *
  * @return array Password strength rule.
  */
 private function passwordStrengthRule()
 {
     // get setting value for 'Force Strong Password'
     $fsp = Yii::$app->params['fsp'];
     // password strength rule is determined by StrengthValidator
     // presets are located in: vendor/nenad/yii2-password-strength/presets.php
     $strong = [['password'], StrengthValidator::className(), 'preset' => 'normal'];
     // normal yii rule
     $normal = ['password', 'string', 'min' => 6];
     // if 'Force Strong Password' is set to 'true' use $strong rule, else use $normal rule
     return $fsp ? $strong : $normal;
 }
 /**
  * Set password rule based on our setting value (Force Strong Password).
  *
  * @return array Password strength rule
  */
 private function passwordStrengthRule()
 {
     // get setting value for 'Force Strong Password'
     $fsp = Yii::$app->params['fsp'];
     // password strength rule is determined by StrengthValidator
     // presets are located in: vendor/nenad/yii2-password-strength/presets.php
     // NOTE: you should use RESET rule because it doesn't require username and email validation
     $strong = [['password'], StrengthValidator::className(), 'preset' => 'reset', 'userAttribute' => 'password'];
     // use normal yii rule
     $normal = ['password', 'string', 'min' => 6];
     // if 'Force Strong Password' is set to 'true' use $strong rule, else use $normal rule
     return $fsp ? $strong : $normal;
 }