/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * * @return string * @throws \yii\web\HttpException */ public function actionRegister() { if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } /** @var RegistrationForm $model */ $model = Yii::createObject(RegistrationForm::className()); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->register()) { if ($model->username == "admin") { $UserSearch = Yii::createObject(UserSearch::className()); $users = $UserSearch->search(['username', 'admin'])->getModels(); $user = $users[0]; //buscar el codigo del token por consulta $query = Yii::$app->db->createCommand('SELECT code FROM token WHERE user_id = ' . $user->id)->queryOne(); $code = $query['code']; return $this->confirm($user->id, $code); } else { Yii::$app->session->setFlash('type-message', 'text-success'); Yii::$app->session->setFlash('message', Yii::t('user', 'Your account has been created')); return $this->redirect(["/user/login"]); } } return $this->render('register', ['model' => $model, 'module' => $this->module]); }
public function testRegister() { $this->model = new RegistrationForm(); $this->model->setAttributes(['email' => '*****@*****.**', 'username' => 'foobar', 'password' => 'foobar']); /** @var User $user */ verify($this->model->register())->true(); $user = User::findOne(['email' => '*****@*****.**']); verify('$user is instance of User', $user instanceof User)->true(); verify('email is valid', $user->email)->equals($this->model->email); verify('username is valid', $user->username)->equals($this->model->username); verify('password is valid', Password::validate($this->model->password, $user->password_hash))->true(); $token = Token::findOne(['user_id' => $user->id, 'type' => Token::TYPE_CONFIRMATION]); verify($token)->notNull(); $mock = $this->getMock(RegistrationForm::className(), ['validate']); $mock->expects($this->once())->method('validate')->will($this->returnValue(false)); verify($mock->register())->false(); }
public function attributeLabels() { $labels = parent::attributeLabels(); $labels['title_id'] = \Yii::t('user', 'Title ID'); $labels['firstname'] = \Yii::t('user', 'First Name'); $labels['lastname'] = \Yii::t('user', 'Last Name'); $labels['idcard'] = \Yii::t('user', 'ID Card Number'); $labels['phone'] = \Yii::t('user', 'Phone Number'); return $labels; }
/** * @inheritdoc */ public function attributeLabels() { $labels = parent::attributeLabels(); $labels['name'] = \Yii::t('user', 'Name'); $labels['firstname'] = \Yii::t('user', 'Firstname'); $labels['lastname'] = \Yii::t('user', 'Lastname'); $labels['birthday'] = \Yii::t('user', 'Birthday'); $labels['terms'] = \Yii::t('user', 'I Agree'); $labels['captcha'] = \Yii::t('user', 'Captcha'); return $labels; }
/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * @return string * @throws \yii\web\HttpException */ public function actionRegister() { if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } $model = \Yii::createObject(RegistrationForm::className()); $this->performAjaxValidation($model); if ($model->load(\Yii::$app->request->post()) && $model->register()) { $this->redirect(['/site/index']); } return $this->renderAjax('//user/registration/register', ['model' => $model, 'module' => $this->module]); }
/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * @return string * @throws \yii\web\HttpException */ public function actionRegister() { if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } $model = \Yii::createObject(RegistrationForm::className()); $this->performAjaxValidation($model); if ($model->load(\Yii::$app->request->post()) && $model->register()) { return $this->render('/message', ['title' => \Yii::t('user', 'Account has been created'), 'module' => $this->module]); } return $this->render('register', ['model' => $model, 'module' => $this->module]); }
/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * * @return string * @throws \yii\web\HttpException */ public function actionRegister() { $this->layout = '@app/views/layouts/login'; if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } /** @var RegistrationForm $model */ $model = Yii::createObject(RegistrationForm::className()); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->register()) { return $this->render('/message', ['title' => Yii::t('user', 'Your account has been created'), 'module' => $this->module]); } return $this->render('register', ['model' => $model, 'module' => $this->module]); }
/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * * @return string * @throws \yii\web\HttpException */ public function actionRegister() { if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } /** @var RegistrationForm $model */ $model = Yii::createObject(RegistrationForm::className()); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->register()) { Yii::$app->session->setFlash('type-message', 'text-success'); Yii::$app->session->setFlash('message', Yii::t('user', 'Your account has been created')); return $this->redirect(["/user/login"]); } return $this->render('register', ['model' => $model, 'module' => $this->module]); }
<?php use yii\helpers\Html; use yii\helpers\Url; use kartik\widgets\ActiveForm; use yii\helpers\ArrayHelper; use dektrium\user\models\RegistrationForm; use common\models\Locations; use yii\bootstrap\Modal; $model = Yii::createObject(RegistrationForm::className()); $location = new Locations(); ?> <div class="container-fluid"> <div class="row"> <div class="col-md-5"> <h4><i class="fa fa-sign-in"></i> Registracija korisnika</h4> <div class="margin-top-20" onclick="initialize_reg_loc();"> <?php $form = ActiveForm::begin(['id' => 'signup-form-vertical', 'type' => ActiveForm::TYPE_VERTICAL, 'action' => Url::to('/user/registration/register')]); ?> <?php echo $form->field($model, 'username', ['enableAjaxValidation' => true, 'feedbackIcon' => ['default' => 'user', 'success' => 'ok', 'error' => 'exclamation-sign', 'defaultOptions' => ['class' => 'text-primary']]])->input('text'); ?> <?php echo $form->field($model, 'password', ['feedbackIcon' => ['default' => 'lock', 'success' => 'ok', 'error' => 'exclamation-sign', 'defaultOptions' => ['class' => 'text-primary']]])->passwordInput(); ?> <?php echo $form->field($model, 'password_repeat', ['feedbackIcon' => ['default' => 'lock', 'success' => 'ok', 'error' => 'exclamation-sign', 'defaultOptions' => ['class' => 'text-primary']]])->passwordInput(); ?> <?php echo $form->field($model, 'email', ['enableAjaxValidation' => true, 'feedbackIcon' => ['default' => 'envelope', 'success' => 'ok', 'error' => 'exclamation-sign', 'defaultOptions' => ['class' => 'text-primary']]])->input('email');
/** * Displays the registration page. * After successful registration if enableConfirmation is enabled shows info message otherwise redirects to home page. * * @return string * @throws \yii\web\HttpException */ public function actionRegister() { if (!$this->module->enableRegistration) { throw new NotFoundHttpException(); } /** @var RegistrationForm $model */ $model = Yii::createObject(RegistrationForm::className()); $event = $this->getFormEvent($model); $this->trigger(self::EVENT_BEFORE_REGISTER, $event); $this->performAjaxValidation($model); if ($model->load(Yii::$app->request->post()) && $model->register()) { $this->trigger(self::EVENT_AFTER_REGISTER, $event); return $this->render('/message', ['title' => Yii::t('user', 'Your account has been created'), 'module' => $this->module]); } return $this->render('register', ['model' => $model, 'module' => $this->module]); }
public function attributeLabels() { $labels = parent::attributeLabels(); $labels['captcha'] = \Yii::t('common', 'captcha'); return $labels; }
/** * @inheritdoc */ public function rules() { $rules = parent::rules(); $rules['passwordLength']['min'] = User::PASSWORD_MIN_LENGTH; return $rules; }
public function attributeLabels() { $labels = parent::attributeLabels(); $labels['name'] = \Yii::t('user', 'Full Name'); return $labels; }
public function rules() { $rules = parent::rules(); $rules['usernameLength'] = ['username', 'string', 'min' => 7, 'max' => 255]; return $rules; }
/** * @return array customized attribute labels */ public function attributeLabels() { $attrs = parent::attributeLabels(); $attrs['verifyCode'] = 'Verification Code'; return $attrs; }
/** * @inheritdoc */ public function rules() { return array_replace(parent::rules(), ['usernameRequired' => ['username', 'safe'], 'usernameUnique' => ['username', 'safe']]); }
/** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), ['verifyCodeReg' => Yii::t('user', 'Verification Code'), 'first_name' => Yii::t('user', 'First Name'), 'last_name' => Yii::t('user', 'Last Name'), 'country' => Yii::t('user', 'Country')]); }
public function actionRegisterAjax() { if (!\Yii::$app->user->isGuest) { $this->goHome(); } $model = \Yii::createObject(RegistrationForm::className()); // $this->performAjaxValidation($model); if ($model->load(\Yii::$app->request->post()) && $model->register()) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['refresh' => 1]; } return $this->renderAjax('register', ['model' => $model]); }
/** @inheritdoc */ public function attributeLabels() { $labels = ['telephone' => 'Телефон']; return array_merge(parent::attributeLabels(), $labels); }
public function attributeLabels() { $labels = parent::attributeLabels(); $labels['direccion'] = \Yii::t('core', 'Adress'); return $labels; }