mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-66984 auth: Allow $USER to be used in change_password_url
This commit is contained in:
parent
aaff6692a1
commit
319577dbbb
@ -766,6 +766,9 @@ class auth_plugin_base {
|
||||
* @return string[] An array of strings with keys subject and message
|
||||
*/
|
||||
public function get_password_change_info(stdClass $user) : array {
|
||||
|
||||
global $USER;
|
||||
|
||||
$site = get_site();
|
||||
$systemcontext = context_system::instance();
|
||||
|
||||
@ -776,6 +779,10 @@ class auth_plugin_base {
|
||||
$data->sitename = format_string($site->fullname);
|
||||
$data->admin = generate_email_signoff();
|
||||
|
||||
// This is a workaround as change_password_url() is designed to allow
|
||||
// use of the $USER global. See MDL-66984.
|
||||
$olduser = $USER;
|
||||
$USER = $user;
|
||||
if ($this->can_change_password() and $this->change_password_url()) {
|
||||
// We have some external url for password changing.
|
||||
$data->link = $this->change_password_url();
|
||||
@ -783,6 +790,7 @@ class auth_plugin_base {
|
||||
// No way to change password, sorry.
|
||||
$data->link = '';
|
||||
}
|
||||
$USER = $olduser;
|
||||
|
||||
if (!empty($data->link) and has_capability('moodle/user:changeownpassword', $systemcontext, $user->id)) {
|
||||
$subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname));
|
||||
|
Loading…
x
Reference in New Issue
Block a user