2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * Nologin authentication login - prevents user login.
20 * @package auth_nologin
22 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
25 defined('MOODLE_INTERNAL') ||
die();
27 require_once($CFG->libdir
.'/authlib.php');
30 * Plugin for no authentication - disabled user.
32 class auth_plugin_nologin
extends auth_plugin_base
{
38 public function __construct() {
39 $this->authtype
= 'nologin';
43 * Old syntax of class constructor. Deprecated in PHP7.
45 * @deprecated since Moodle 3.1
47 public function auth_plugin_nologin() {
48 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER
);
53 * Do not allow any login.
56 function user_login($username, $password) {
61 * No password updates.
63 function user_update_password($user, $newpassword) {
67 function prevent_local_passwords() {
68 // just in case, we do not want to loose the passwords
73 * No external data sync.
77 function is_internal() {
78 //we do not know if it was internal or external originally
83 * No changing of password.
87 function can_change_password() {
92 * No password resetting.
94 function can_reset_password() {
99 * Returns true if plugin can be manually set.
103 function can_be_manually_set() {
108 * Returns information on how the specified user can change their password.
109 * User accounts with authentication type set to nologin are disabled accounts.
110 * They cannot change their password.
112 * @param stdClass $user A user object
113 * @return string[] An array of strings with keys subject and message
115 public function get_password_change_info(stdClass
$user) : array {
118 $data = new stdClass();
119 $data->firstname
= $user->firstname
;
120 $data->lastname
= $user->lastname
;
121 $data->username
= $user->username
;
122 $data->sitename
= format_string($site->fullname
);
123 $data->admin
= generate_email_signoff();
125 $message = get_string('emailpasswordchangeinfodisabled', '', $data);
126 $subject = get_string('emailpasswordchangeinfosubject', '', format_string($site->fullname
));
129 'subject' => $subject,
130 'message' => $message