Ejemplo n.º 1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = SysUserIdentity::findByUsername($this->username);
         if (!$this->_user) {
             $this->_user = SysUserIdentity::findByEmail($this->username);
         }
     }
     return $this->_user;
 }
Ejemplo n.º 2
0
 /**
  * 
  * @param string $token
  * @return string|\yii\web\Response
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionPasswordRecoveryReceive($token)
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $user = SysUserIdentity::findIdentityByConfirmationToken($token);
     if (!$user) {
         throw new \yii\web\NotFoundHttpException(Yii::t('app', 'Token not found. It may be expired. Try reset password once more'));
     }
     $model = new SysChangeOwnPasswordForm(['user' => $user]);
     if ($model->load(Yii::$app->request->post()) and $model->validate()) {
         if ($model->changePassword()) {
             return $this->render('change-password-success');
         } else {
             Yii::$app->session->setFlash('error', Yii::t('app', 'The password cannot be changed.'));
         }
     }
     return $this->render('change-password', ['model' => $model]);
 }