catalyst / moodle-auth_saml2

SAML done 100% in Moodle, fast, simple, secure
https://moodle.org/plugins/auth_saml2
72 stars 134 forks source link

notice when there is no matched user #126

Closed jamiepratt closed 5 years ago

jamiepratt commented 7 years ago

When logging in if there is no matched user in the system I get a notice message :

Notice: Trying to get property of non-object in /mnt/drive/www/ehs/auth/saml2/auth.php on line 307 Call Stack: 0.0001 234656 1. {main}() /mnt/drive/www/ehs/auth/saml2/login.php:0 0.0238 3460648 2. auth_plugin_saml2->saml_login() /mnt/drive/www/ehs/auth/saml2/login.php:34

Line 307 reads :

        if ($user->suspended) {
            $this->error_page(get_string('suspendeduser', 'auth_saml2', $uid));
        }

This is before the place where we test if the user was found and create a new one if necessary on line 312 :

        if (!$user) {
            if ($this->config->autocreate) {
                $this->log(__FUNCTION__ . " user '$uid' is not in moodle so autocreating");
                $user = create_user_record($uid, '', 'saml2');
                $newuser = true;
            } else {
jamiepratt commented 7 years ago

I'm writing a fix, I'll send a pull request in a few minutes.

brendanheywood commented 5 years ago

Fixed ages ago