/** * Finds user by [[username]] * @return UserIdentity|null */ public function getUser() { if ($this->_user === null) { $this->_user = UserIdentity::findByUsername($this->username); } return $this->_user; }
/** * @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']]; }
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', []); }