MDL-59298 auth_nologin: override get_password_change_info

Let the auth_nologin class to take care of its exceptional behaviour.
This commit is contained in:
Shamim Rezaie 2019-03-26 01:19:23 +11:00
parent 206ec32890
commit 4c00766e2a
2 changed files with 28 additions and 1 deletions

View File

@ -103,6 +103,33 @@ class auth_plugin_nologin extends auth_plugin_base {
function can_be_manually_set() {
return true;
}
/**
* Returns information on how the specified user can change their password.
* User accounts with authentication type set to nologin are disabled accounts.
* They cannot change their password.
*
* @param stdClass $user A user object
* @return string[] An array of strings with keys subject and message
*/
public function get_password_change_info(stdClass $user) : array {
$site = get_site();
$data = new stdClass();
$data->firstname = $user->firstname;
$data->lastname = $user->lastname;
$data->username = $user->username;
$data->sitename = format_string($site->fullname);
$data->admin = generate_email_signoff();
$message = get_string('emailpasswordchangeinfodisabled', '', $data);
$subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname));
return [
'subject' => $subject,
'message' => $message
];
}
}

View File

@ -6422,7 +6422,7 @@ function send_password_change_info($user) {
$data->sitename = format_string($site->fullname);
$data->admin = generate_email_signoff();
if (!is_enabled_auth($user->auth) or $user->auth == 'nologin') {
if (!is_enabled_auth($user->auth)) {
$message = get_string('emailpasswordchangeinfodisabled', '', $data);
$subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname));
// Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.