diff --git a/lib/authlib.php b/lib/authlib.php index cfb71cb2924..c6f7873f4b0 100644 --- a/lib/authlib.php +++ b/lib/authlib.php @@ -1156,7 +1156,9 @@ function signup_validate_data($data, $files) { // Construct fake user object to check password policy against required information. $tempuser = new stdClass(); - $tempuser->id = 1; + // To prevent errors with check_password_policy(), + // the temporary user and the guest must not share the same ID. + $tempuser->id = (int)$CFG->siteguest + 1; $tempuser->username = $data['username']; $tempuser->firstname = $data['firstname']; $tempuser->lastname = $data['lastname']; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 9c7476030b3..38e05cd2a15 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5048,7 +5048,7 @@ function get_complete_user_data($field, $value, $mnethostid = null, $throwexcept function check_password_policy($password, &$errmsg, $user = null) { global $CFG; - if (!empty($CFG->passwordpolicy)) { + if (!empty($CFG->passwordpolicy) && !isguestuser($user)) { $errmsg = ''; if (core_text::strlen($password) < $CFG->minpasswordlength) { $errmsg .= '
'. get_string('errorminpasswordlength', 'auth', $CFG->minpasswordlength) .'
';