moodle/moodle · error · moodle_exception
errorpasswordupdate
Error message
errorpasswordupdate
What it means
This \moodle_exception('errorpasswordupdate', 'auth') is thrown in core_login_process_password_set (public/login/lib.php:293) when the auth plugin's user_update_password($user, $data->password) call returns false after the user submitted the set-password form. The one-use token has already been deleted at this point, so the reset flow aborts with an auth-plugin-level failure. The error string comes from the auth language pack ('auth'), indicating the plugin could not persist the new password.
Solutions
- Check which auth plugin the user has and its configuration (Site administration > Plugins > Authentication > <plugin>): ensure password changes are supported (e.g. LDAP 'binddn' with write permission, or switch the user to 'manual' auth).
- Enable debugging and the auth plugin's own logs to see the backend error returned by user_update_password (LDAP error code, DB exception).
- If the plugin cannot change passwords, an admin sets the password via the user edit page or CLI: php admin/cli/reset_password.php, using an auth plugin that supports it.
- Note the reset token was already consumed - after fixing the plugin, have the user request a new reset link from login/forgot_password.php.
- Verify the mdl_user table schema/password column is writable (no read-only replica or trigger blocking the UPDATE).
Example fix
// before: LDAP auth plugin without write bind configured $CFG->auth = 'ldap'; // ldap_binddn has read-only rights -> user_update_password() returns false // after: either grant the binddn write rights, or move user to manual auth UPDATE mdl_user SET auth = 'manual' WHERE username = 'jane';
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the auth plugin can actually update passwords before entering the flow
$authplugin = \core\di::get(\core\authentication::class)->get_plugin($user->auth);
if (!method_exists($authplugin, 'user_update_password') || !$authplugin->can_reset_password()) {
// password changes unsupported for this user's auth method; use admin reset instead
} Try / catch
try {
core_login_process_password_set($token);
} catch (\moodle_exception $e) {
if ($e->errorcode === 'errorpasswordupdate') {
debugging('Auth plugin failed to update password: ' . $e->debuginfo, DEBUG_DEVELOPER);
// send the user back to forgot_password.php for a fresh token after the plugin is fixed
redirect($CFG->wwwroot . '/login/forgot_password.php');
}
} Prevention
- Give external-auth bind accounts (LDAP/AD) write rights if self-service password change is intended.
- Confirm the auth plugin implements user_update_password (not a stub) before advertising self-service resets.
- Test password policy compliance against the external directory to avoid backend rejections.
- Keep auth plugins updated; verify with a test user after Moodle upgrades.
- Watch for partially consumed tokens: the token is deleted before the update, so failures require a fresh reset request.
When it happens
Trigger: Specifically: user submits login_set_password_form with a valid token; $DB->delete_records('user_password_resets', ...) succeeds; \core\di::get(\core\authentication::class)->get_plugin($user->auth)->user_update_password($user, $data->password) returns false - e.g. LDAP bind/write failure, external auth backend unreachable, plugin does not implement password updates, or DB constraint on mdl_user (password column) fails.
Common situations: LDAP/external auth plugin configured without write credentials ('binddn' lacking change-password rights); the plugin's user_update_password is a stub returning false (method-not-implemented style); the directory server rejects the password policy (too weak/history); database issue writing the bcrypt hash; auth plugin changed for the user mid-flow so the plugin loaded can't handle updates.
Related errors
- auth_ldap_ad_create_req
- auth_ldap_ad_invalidchars
- auth_ldap_create_error
- auth_ldap_no_mbstring
- auth_ldap_noconnect_all
AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14).
Data as JSON: /api/errors/358f1a2dc6074cbf.
Report an issue: GitHub.
Appendix: source
Thrown at public/login/lib.php:293
// User hasn't submitted form, they got here directly from email link.
// Next, display the form.
$setdata = new stdClass();
$setdata->username = $user->username;
$setdata->username2 = s($user->username);
$setdata->token = $user->token;
$mform->set_data($setdata);
echo $OUTPUT->header();
echo $OUTPUT->box(get_string('setpasswordinstructions'), 'generalbox boxwidthnormal boxaligncenter');
$mform->display();
echo $OUTPUT->footer();
return;
} else {
// User has submitted form.
// Delete this token so it can't be used again.
$DB->delete_records('user_password_resets', array('id' => $user->tokenid));
$userauth = \core\di::get(\core\authentication::class)->get_plugin($user->auth);
if (!$userauth->user_update_password($user, $data->password)) {
throw new \moodle_exception('errorpasswordupdate', 'auth');
}
\core\user::add_password_history($user->id, $data->password);
if (!empty($CFG->passwordchangelogout) || !empty($data->logoutothersessions)) {
\core\session\manager::destroy_user_sessions($user->id, session_id());
}
// Reset login lockout (if present) before a new password is set.
login_unlock_account($user);
// Clear any requirement to change passwords.
unset_user_preference('auth_forcepasswordchange', $user);
unset_user_preference('create_password', $user);
if (!empty($user->lang)) {
// Unset previous session language - use user preference instead.
unset($SESSION->lang);
}
complete_user_login($user); // Triggers the login event.
\core\session\manager::apply_concurrent_login_limit($user->id, session_id());View on GitHub (pinned to 48ea8c3322)