]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9429 make clear that alternate change password url is used only when user is...
authorskodak <skodak>
Fri, 20 Apr 2007 10:02:38 +0000 (10:02 +0000)
committerskodak <skodak>
Fri, 20 Apr 2007 10:02:38 +0000 (10:02 +0000)
lib/authlib.php
lib/moodlelib.php
login/change_password.php
login/index.php
user/view.php

index 57f05f91d269d0e2323ef440cc41139dcba95553..f64a32cc0b59ba99108e330e9840643de6b5a54d 100644 (file)
@@ -87,6 +87,7 @@ class auth_plugin_base {
     /**
      * Returns the URL for changing the users' passwords, or empty if the default
      * URL can be used. This method is used if can_change_password() returns true.
+     * This method is called only when user is logged in, it may use global $USER.
      *
      * @return string
      */
index bcbf4f078c698f17eef2828d53058e19c6b8f46c..b8311cf81ff9a0de5c0a65f34c2b886580ab32f4 100644 (file)
@@ -1665,9 +1665,9 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null) {
     if (get_user_preferences('auth_forcepasswordchange') && empty($USER->realuser)) {
         if ($userauth->can_change_password()) {
             $SESSION->wantsurl = $FULLME;
-            if ($userauth->change_password_url()) {
+            if ($changeurl = $userauth->change_password_url()) {
                 //use plugin custom url
-                redirect($userauth->change_password_url());
+                redirect($changeurl);
             } else {
                 //use moodle internal method
                 if (empty($CFG->loginhttps)) {
index 0e8c1fd2968cb7b2b0cba259dd6e46c47f4ef2dc..6a6b938b720b068965e54c0d20342d3b48ef5411 100644 (file)
@@ -43,9 +43,9 @@
         error(get_string('nopasswordchange', 'auth'));
     }
 
-    if ($userauth->change_password_url()) {
+    if ($changeurl = $userauth->change_password_url()) {
         // this internal scrip not used
-        redirect($userauth->change_password_url());
+        redirect($changeurl);
     }
 
     $mform = new login_change_password_form();
index 5f1aa4f2bc4e43b8b3346714118a0ff2559bfd5a..0ee0c170d0da93f554b970d795a9eb84ff05c1ab 100644 (file)
@@ -25,6 +25,7 @@
 
 /// Check if the guest user exists.  If not, create one.
     if (! record_exists('user', 'username', 'guest')) {
+        $guest = new object();
         $guest->auth        = 'manual'; 
         $guest->username    = 'guest'; 
         $guest->password    = hash_internal_user_password('guest');
@@ -177,25 +178,19 @@ httpsrequired();
 
             /// This is what lets the user do anything on the site :-)
             load_all_capabilities();
-
-            //Select password change url
             $userauth = get_auth_plugin($USER->auth);
-            if ($userauth->can_change_password()) {
-                if ($userauth->change_password_url()) {
-                    $passwordchangeurl = $userauth->change_password_url();
-                } else {
-                    $passwordchangeurl = $CFG->httpswwwroot.'/login/change_password.php';
-                }
-            } else {
-                $passwordchangeurl = '';
-            }
 
             // check whether the user should be changing password
             if (get_user_preferences('auth_forcepasswordchange', false) || $frm->password == 'changeme'){
-                if ($passwordchangeurl != '') {
-                    redirect($passwordchangeurl);
+                //Select password change url
+                if ($userauth->can_change_password()) {
+                    if ($changeurl = $userauth->change_password_url()) {
+                        redirect($changeurl);
+                    } else {
+                        redirect($CFG->httpswwwroot.'/login/change_password.php');
+                    }
                 } else {
-                    error(get_strin('nopasswordchangeforced', 'auth'));
+                    error(get_string('nopasswordchangeforced', 'auth'));
                 }
             }
 
index 208809e89cfd337d3eda7cdf3ec447eeb4d12642..81eb4f92b37f9929a17ab5852aa25a7ad319a958 100644 (file)
     $userauth = get_auth_plugin($user->auth);
 
     $passwordchangeurl = false;
-    if ($userauth->can_change_password()) {
+    if ($currentuser and $userauth->can_change_password() and !isguest()) { //TODO: add proper capability for password changing
         if ($userauth->change_password_url()) {
             $passwordchangeurl = $userauth->change_password_url();
         } else {
 //  Print other functions
     echo '<div class="buttons">';
 
-    if ($currentuser and $passwordchangeurl and !isguest()) { //TODO: add proper capability for password changing
+    if ($passwordchangeurl) {
+        if (!empty($USER->realuser)) {
+            $passwordchangeurl = ''; // do not use actual change password url - might contain sensitive data
+        }
         echo "<form action=\"$passwordchangeurl\" method=\"get\">";
         echo "<div>";
         echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";