Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enable reset password functinoality for LDAP and other external auth …

…mechanisms as promised in the auth config page
  • Loading branch information...
commit 0b7c88413267303711d66362a922d3ef41657381 1 parent cf03711
martinlanghoff authored
Showing with 24 additions and 4 deletions.
  1. +20 −2 lib/moodlelib.php
  2. +4 −2 login/index_form.html
View
22 lib/moodlelib.php
@@ -3579,10 +3579,28 @@ function reset_password_and_mail($user) {
$site = get_site();
$from = get_admin();
+ $external = false;
+ if (!is_internal_auth($user->auth)) {
+ include_once($CFG->dirroot . '/auth/' . $user->auth . '/lib.php');
+ if (empty($CFG->{'auth_'.$user->auth.'_stdchangepassword'})
+ || !function_exists('auth_user_update_password')) {
+ trigger_error("Attempt to reset user password for user $user->username with Auth $user->auth.");
+ return false;
+ } else {
+ $external = true;
+ }
+ }
+
$newpassword = generate_password();
- if (! set_field('user', 'password', md5($newpassword), 'id', $user->id) ) {
- error('Could not set user password!');
+ if ($external) {
+ if (!auth_user_update_password($user->username, $newpassword)) {
+ error("Could not set user password!");
+ }
+ } else {
+ if (! set_field("user", "password", md5($newpassword), "id", $user->id) ) {
+ error("Could not set user password!");
+ }
}
$a->firstname = $user->firstname;
View
6 login/index_form.html
@@ -55,8 +55,10 @@
</form>
<?php } ?>
-<?php if ($CFG->changepassword or is_internal_auth() ) {
- if (is_internal_auth()) {
+<?php if (!empty($CFG->{'auth_'.$CFG->auth.'_stdchangepassword'})
+ || $CFG->changepassword
+ || is_internal_auth() ) {
+ if (is_internal_auth() || !empty($CFG->{'auth_'.$CFG->auth.'_stdchangepassword'})) {
$changepassword = "forgot_password.php";
$changebuttonname = get_string("senddetails");
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.