Exemple #1
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     $rules = [[['email', 'password', 'password_repeat', 'tos'], 'required', 'except' => ['account']], ['current_password', 'required'], ['current_password', 'validateCurrentPassword'], [['email', 'new_email'], 'email', 'message' => Yii::t('podium/view', 'This is not a valid e-mail address.')], [['email', 'new_email'], 'string', 'max' => 255, 'message' => Yii::t('podium/view', 'Provided e-mail address is too long.')], ['email', 'unique'], ['new_email', 'unique', 'targetAttribute' => 'email'], ['password', 'passwordRequirements'], ['password_repeat', 'compare', 'compareAttribute' => 'password'], ['username', 'unique'], ['username', 'validateUsername'], ['anonymous', 'boolean'], ['inherited_id', 'integer'], ['timezone', 'match', 'pattern' => '/[\\w\\-]+/'], ['status', 'default', 'value' => self::STATUS_REGISTERED], ['role', 'default', 'value' => self::ROLE_MEMBER], ['tos', 'in', 'range' => [1], 'message' => Yii::t('podium/view', 'You have to read and agree on ToS.')]];
     if (Config::getInstance()->get('recaptcha_sitekey') !== '' && Config::getInstance()->get('recaptcha_secretkey') !== '') {
         $rules[] = ['captcha', RecaptchaValidator::className(), 'secret' => Config::getInstance()->get('recaptcha_secretkey')];
     } else {
         $rules[] = ['captcha', 'captcha', 'captchaAction' => 'podium/account/captcha'];
     }
     return $rules;
 }
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['username', 'password'], 'required'], ['rememberMe', 'boolean'], ['password', 'validatePassword'], ['captcha', RecaptchaValidator::className(), 'secret' => Yii::$app->config->get(Enum::RECAPTCHA_SECRET)]];
 }