/** * Validation rules * * @see CModel::rules() * * @return array */ public function rules() { $rules = parent::rules(); $rules[] = array('username', 'email'); $rules[] = array('verifyCode', 'validateCaptcha', 'message' => Yii::t('translation', "Captcha does not match")); return $rules; }
/** * Declares the validation rules. */ public function rules() { $rules = CMap::mergeArray(parent::rules(), array(array('textPassword, verifyPassword, verifyEmail, verifyCode', 'required'), array('textPassword', 'length', 'max' => 128, 'min' => 6, 'message' => UserModule::t("Incorrect password (minimal length 6 symbols).")), array('verifyPassword', 'compare', 'compareAttribute' => 'textPassword', 'message' => UserModule::t("Retype Password is incorrect.")), array('verifyEmail', 'compare', 'compareAttribute' => 'email', 'message' => UserModule::t("Retype Email is incorrect.")))); if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') { return $rules; } else { array_push($rules, array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements())); } return $rules; }
public function testRegistration() { User::where('username', 'testuser')->delete(); $this->action('POST', 'AuthController@store', ['first_name' => 'Unit', 'last_name' => 'Test', 'username' => 'testuser', 'email' => '*****@*****.**', 'password' => 'testuser', 'password_confirmation' => 'testuser']); $this->assertRedirectedToAction('AuthController@login'); User::$rules = []; $this->getUser(); $this->user->confirmation_code = md5(uniqid(mt_rand(), true)); $this->user->save(); }
/** * testing method return array type */ public function testTypeFunction() { $model = new User(); $model->login = "******"; $model->password = "******"; $model->profil = "clinicien"; $model->nom = "testNom"; $model->prenom = "testPrénom"; $model->email = "*****@*****.**"; $model->telephone = "0123456789"; $model->address = "5 rue Marat"; $model->centre = "Paris"; $criteria = new EMongoCriteria(); $criteria->login = "******"; $user = User::model()->find($criteria); $this->assertInternalType('object', $model->model()); $this->assertInternalType('array', $model->rules()); $this->assertInternalType('array', $model->attributeLabels()); $this->assertInternalType('array', $model->getAllUsersLastnames()); $this->assertInternalType('array', $model->getAllUsersFirstnames()); $this->assertInternalType('array', $model->getAllUsersLogin()); $this->assertInternalType('array', $model->getAllUsersEmail()); $this->assertInternalType('array', $model->getAllUsersByLogin($model)); $model->profil = "clinicien"; $this->assertInternalType('string', $model->getProfil()); $model->profil = ""; $this->assertInternalType('string', $model->getProfil()); $this->assertInternalType('array', $model->getArrayProfil()); $this->assertInternalType('object', $model->getArrayProfilSorted()); $this->assertInternalType('array', $model->getArrayProfilFiltered()); $this->assertInternalType('array', $model->getArrayAvailableProfil($user->_id)); $this->assertInternalType('array', $model->getArrayCentre()); $this->assertNull($model->passwordValidator()); $this->assertNull($model->telValidator()); $this->assertNull($model->gsmValidator()); $this->assertNull($model->alphaOnly()); $this->assertNull($model->alphaNumericOnly()); $this->assertNull($model->addressValidator()); $this->assertNull($model->centreValidator()); $model->profil = array(); $model->profil[] = "administrateur"; $this->assertInternalType('string', $model->getDefaultProfil()); $model->profil = array(); $model->profil[] = "neuropathologiste"; $this->assertInternalType('string', $model->getDefaultProfil()); $model->profil = array(); $model->profil[] = "geneticien"; $this->assertInternalType('string', $model->getDefaultProfil()); $model->profil = array(); $model->profil[] = "clinicien"; $this->assertInternalType('string', $model->getDefaultProfil()); $model->profil = array(); $model->profil[] = "chercheur"; $this->assertInternalType('string', $model->getDefaultProfil()); }
public function post_signup() { $data = Input::all(); $data['temp_code'] = str_random(60); $data['active'] = 1; $messages = array('unique' => 'Account for ' . $data['email'] . 'already exists. Please sign in.', 'same' => 'The \'Password\' and \'confirm password\' do not match', 'required' => 'All the fields are mandatory'); $validator = Validator::make($data, User::rules(), $messages); if ($validator->fails()) { return Redirect::route('account-signup')->withErrors($validator)->withInput(); } else { $password = Hash::make($data['password']); $data['password'] = $password; $user = User::create($data); if ($user) { return Redirect::intended('/'); } else { return Redirect::route('account-signup')->with('message', 'The registration process cannot be completed at the moment. Please try again later')->with('type', 'danger'); } } }
public function rules() { $rules = array(array('email', 'required'), array('email', 'email', 'allowEmpty' => false), array('email', 'unique'), array('reTypePassword,password', 'required'), array('reTypePassword', 'reType')); return array_merge(parent::rules(), $rules); }
public function rules() { return array_merge(parent::rules(), [[['password', 'passwordRepeat'], 'required'], [['passwordRepeat'], 'compare', 'compareAttribute' => 'password']]); }
public function rules() { $rules = array(array('changePassword, repeatPassword', 'editPassword')); return array_merge($rules, parent::rules()); }
public static function setRules($name) { self::$rules = self::$_rules[$name]; }
/** * @return array|mixed */ public function rules() { return CMap::mergeArray(parent::rules(), [['id, update_time, create_time, middle_name, first_name, last_name, nick_name, email, gender, avatar, status, access_level, visit_time, phone, ordersTotalNumber, ordersTotalSum', 'safe', 'on' => 'search']]); }
public function rules() { return array_merge(parent::rules(), array(array("email", "required"), array("email", "length", "max" => 255, "tooLong" => "Слишком длинный адрес электронной почты"), array("email", "email", "checkPort" => false, "message" => "Неверный адрес электронной почты."), array("email", "unique", "className" => "User", "caseSensitive" => false, "criteria" => new CDbCriteria(array("condition" => "id != " . Yii::app()->user->id)), "message" => "Пользователь с таким адресом электронной почты уже зарегистрирован."), array("sex", "in", "range" => array("x", "m", "f"), "message" => "Вы должны быть либо мужчиной, либо, ещё лучше, женщиной."), array("new_pass, new_pass2", "filter", "filter" => "trim"), array("new_pass, new_pass2", "length", "min" => 5, "max" => 32, "tooShort" => "Слишком короткий новый пароль.", "tooLong" => "Слишком длинный новый пароль."), array("new_pass2", "compare", "compareAttribute" => "new_pass", "message" => "Новые пароли не совпадают, вы где-то опечатались."), array("old_pass", "change_pass"), array("set_ini", "set_ini"))); }
public function rules() { return array_merge(parent::rules(), array(array("name, icq, lj, url, skype, bdate_y, bdate_m, bdate_d, country_id, city, bio", "safe"), array("name, icq, lj, url, skype, city", "clean"), array("bio", "safehtml"), array("bdate_y, bdate_m, bdate_d, country_id", "numerical", "integerOnly" => true), array("icq", "match", "pattern" => '/^[\\d -]+$/', "message" => "номер icq может состоять только из цифр и дефисов"), array("lj", "match", "pattern" => '/^[a-z\\d_-]+$/i', "message" => "введите ваш ник в ЖЖ"), array("url", "url", "defaultScheme" => "http", "message" => "это не похоже на адрес сайта"), array("rm_upic", "boolean"), array("new_upic", "file", "allowEmpty" => true, "types" => "jpg, gif, png, jpeg", "wrongType" => "Неверный формат файла. Пожалуйста, загружайте JPG, PNG или GIF"))); }