Skip to content

Commit

Permalink
MDL-42097 auth: Auth plugins must check passwordurl before returning it
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Dec 3, 2013
1 parent 6513cc0 commit 963cdce
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion auth/db/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ function can_change_password() {
* @return moodle_url
*/
function change_password_url() {
if ($this->is_internal()) {
if ($this->is_internal() || empty($this->config->changepasswordurl)) {
// Standard form.
return null;
} else {
Expand Down
6 changes: 5 additions & 1 deletion auth/imap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function can_change_password() {
* @return moodle_url
*/
function change_password_url() {
return new moodle_url($this->config->changepasswordurl);
if (!empty($this->config->changepasswordurl)) {
return new moodle_url($this->config->changepasswordurl);
} else {
return null;
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,11 @@ function can_change_password() {
*/
function change_password_url() {
if (empty($this->config->stdchangepassword)) {
return new moodle_url($this->config->changepasswordurl);
if (!empty($this->config->changepasswordurl)) {
return new moodle_url($this->config->changepasswordurl);
} else {
return null;
}
} else {
return null;
}
Expand Down
6 changes: 5 additions & 1 deletion auth/pop3/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function can_change_password() {
* @return moodle_url
*/
function change_password_url() {
return new moodle_url($this->config->changepasswordurl);
if (!empty($this->config->changepasswordurl)) {
return new moodle_url($this->config->changepasswordurl);
} else {
return null;
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions auth/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
This files describes API changes in /auth/* - plugins,
information provided here is intended especially for developers.

=== 2.7 ===

* If you are returning a url in method change_password_url() from config, please make sure it is set before trying to use it.

=== 2.6 ===

* can_be_manually_set() - This function was introduced in the base class and returns false by default. If overriden by
Expand Down
2 changes: 2 additions & 0 deletions lib/authlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ function can_change_password() {
*
* 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.
* If you are using a plugin config variable in this method, please make sure it is set before using it,
* as this method can be called even if the plugin is disabled, in which case the config values won't be set.
*
* @return moodle_url url of the profile page or null if standard used
*/
Expand Down

0 comments on commit 963cdce

Please sign in to comment.