/** * Finds user model by the form given username. * @return User|null current user model. * If null, it means the current user model will be not found with this username. */ public function getUser() { if (!$this->_user instanceof User) { $this->_user = User::findByEmail($this->email); } return $this->_user; }
/** * Finds user model by the form given username. * @return User|null current user model. * If null, it means the current user model will be not found with this username. */ public function getUser() { if (!isset($this->_user)) { if ($this->scenario == 'email') { $this->_user = User::findByEmail($this->email); } elseif ($this->scenario == 'token') { $this->_user = User::findOne(['password_change_token' => $this->token]); } } return $this->_user; }