Exemplo n.º 1
0
 /**
  * Finds user by [[username]]
  * @return UserIdentity|null
  */
 public function getUser()
 {
     if ($this->_user === null) {
         $this->_user = UserIdentity::findByUsername($this->username);
     }
     return $this->_user;
 }
Exemplo n.º 2
0
 /**
  * @return array the validation rules.
  */
 public function rules()
 {
     return [['email', 'required'], ['email', 'exist', 'targetAttribute' => 'email', 'targetClass' => User::className(), 'message' => Yii::t('app', 'This email is not registered in the system.')], ['email', 'email']];
 }
Exemplo n.º 3
0
 public function actionActivation()
 {
     $activationHash = Yii::$app->request->get(self::HASH_PARAM_NAME);
     $user = User::find()->where(['activation_hash' => $activationHash])->one();
     if (!$user) {
         throw new HttpException(400, Yii::t('app', 'Bad security code'));
     }
     $user->activation_hash = null;
     $complete = $user->save(false);
     $alert = \yii\bootstrap\Alert::widget(['options' => ['class' => 'alert-success'], 'body' => Yii::t('app', 'Activation finished successfully. You can log in now')]);
     if ($complete) {
         Yii::$app->getSession()->setFlash('successActivation', $alert);
     }
     return $this->render('activation', []);
 }