amnah\yii2\user\Module::checkModuleProperties PHP Method

checkModuleProperties() protected method

Check for valid email/username properties
protected checkModuleProperties ( )
    protected function checkModuleProperties()
    {
        // set use fields based on required fields
        if ($this->requireEmail) {
            $this->useEmail = true;
        }
        if ($this->requireUsername) {
            $this->useUsername = true;
        }
        // get class name for error messages
        $className = get_called_class();
        // check required fields
        if (!$this->requireEmail && !$this->requireUsername) {
            throw new InvalidConfigException("{$className}: \$requireEmail and/or \$requireUsername must be true");
        }
        // check login fields
        if (!$this->loginEmail && !$this->loginUsername) {
            throw new InvalidConfigException("{$className}: \$loginEmail and/or \$loginUsername must be true");
        }
        // check email fields with emailConfirmation/emailChangeConfirmation is true
        if (!$this->useEmail && ($this->emailConfirmation || $this->emailChangeConfirmation)) {
            $msg = "{$className}: \$useEmail must be true if \$email(Change)Confirmation is true";
            throw new InvalidConfigException($msg);
        }
        // ensure that the "user" component is set properly
        // this typically causes problems in the yii2-advanced app when people set it in
        // "common/config" instead of "frontend/config" and/or "backend/config"
        //   -> this results in users failing to login without any feedback/error message
        $userComponent = Yii::$app->get('user', false);
        if ($userComponent && !$userComponent instanceof \amnah\yii2\user\components\User) {
            throw new InvalidConfigException('Yii::$app->user is not set properly. It needs to extend \\amnah\\yii2\\user\\components\\User');
        }
    }