mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-76109 core: Don't check password policy for guest user
Besides adding the is_guest() check in the check_password_policy() condition, I also changed the temporary user ID because the temporary user and the guest must not share the same ID. Otherwise, it will raise an error. Co-authored-by: Andrei Bautu <abautu@gmail.com>
This commit is contained in:
parent
b1bb5671df
commit
f16b42d013
@ -1113,7 +1113,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'];
|
||||
|
@ -4966,7 +4966,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 .= '<div>'. get_string('errorminpasswordlength', 'auth', $CFG->minpasswordlength) .'</div>';
|
||||
|
Loading…
x
Reference in New Issue
Block a user