示例#1
0
 /**
  * Find a user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::findByUserName($this->username);
     }
     return $this->_user;
 }
示例#2
0
 /**
  * Creates a form model given a token.
  *
  * @param  string $token
  * @param  array $config name-value pairs that will be used to initialize the object properties
  * @throws \yii\base\InvalidParamException if token is empty or not valid
  */
 public function __construct($token, $config = [])
 {
     if (empty($token) || !is_string($token)) {
         throw new InvalidParamException(Yii::t('cms', Yii::t('cms', 'Password reset token cannot be blank.')));
     }
     $this->_user = User::findByPasswordResetToken($token);
     if (!$this->_user) {
         throw new InvalidParamException(Yii::t('cms', Yii::t('cms', 'Wrong password reset token.')));
     }
     parent::__construct($config);
 }
示例#3
0
 /**
  * Returns the editor of this page.
  *
  * @return ActiveQueryInterface the relational query object.
  */
 public function getEditor()
 {
     if ($this->updated_by == $this->created_by) {
         return $this->getAuthor();
     }
     return $this->hasOne(User::className(), ['id' => 'updated_by']);
 }
示例#4
0
 /**
  * Renders a list of users.
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => User::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'model' => $this->getModel()]);
 }