2007-01-04 04:52:42 +00:00
|
|
|
<?php
|
2013-04-27 15:06:40 +02:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2007-01-04 04:52:42 +00:00
|
|
|
|
|
|
|
/**
|
2013-04-27 15:06:40 +02:00
|
|
|
* Anobody can login with any password.
|
|
|
|
*
|
|
|
|
* @package auth_none
|
2007-01-04 04:52:42 +00:00
|
|
|
* @author Martin Dougiamas
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
|
|
|
*/
|
|
|
|
|
2013-04-27 15:09:05 +02:00
|
|
|
defined('MOODLE_INTERNAL') || die();
|
2007-01-04 04:52:42 +00:00
|
|
|
|
2007-03-22 12:27:52 +00:00
|
|
|
require_once($CFG->libdir.'/authlib.php');
|
|
|
|
|
2007-01-04 04:52:42 +00:00
|
|
|
/**
|
|
|
|
* Plugin for no authentication.
|
|
|
|
*/
|
2007-03-22 12:27:52 +00:00
|
|
|
class auth_plugin_none extends auth_plugin_base {
|
2007-01-04 04:52:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*/
|
|
|
|
function auth_plugin_none() {
|
2007-03-22 12:27:52 +00:00
|
|
|
$this->authtype = 'none';
|
2007-01-04 04:52:42 +00:00
|
|
|
$this->config = get_config('auth/none');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the username and password work or don't exist and false
|
|
|
|
* if the user exists and the password is wrong.
|
|
|
|
*
|
|
|
|
* @param string $username The username
|
|
|
|
* @param string $password The password
|
2007-02-20 17:03:36 +00:00
|
|
|
* @return bool Authentication success or failure.
|
2007-01-04 04:52:42 +00:00
|
|
|
*/
|
|
|
|
function user_login ($username, $password) {
|
2008-05-30 20:54:19 +00:00
|
|
|
global $CFG, $DB;
|
|
|
|
if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
|
2007-01-04 04:52:42 +00:00
|
|
|
return validate_internal_user_password($user, $password);
|
|
|
|
}
|
2007-03-20 07:55:54 +00:00
|
|
|
return true;
|
2007-01-04 04:52:42 +00:00
|
|
|
}
|
|
|
|
|
2007-01-28 22:08:59 +00:00
|
|
|
/**
|
2007-01-04 04:52:42 +00:00
|
|
|
* Updates the user's password.
|
|
|
|
*
|
|
|
|
* called when the user password is updated.
|
|
|
|
*
|
2008-05-31 17:48:51 +00:00
|
|
|
* @param object $user User table object
|
|
|
|
* @param string $newpassword Plaintext password
|
2007-01-04 04:52:42 +00:00
|
|
|
* @return boolean result
|
|
|
|
*
|
|
|
|
*/
|
2007-01-28 10:27:05 +00:00
|
|
|
function user_update_password($user, $newpassword) {
|
|
|
|
$user = get_complete_user_data('id', $user->id);
|
2012-09-30 20:58:13 +13:00
|
|
|
// This will also update the stored hash to the latest algorithm
|
|
|
|
// if the existing hash is using an out-of-date algorithm (or the
|
|
|
|
// legacy md5 algorithm).
|
2007-01-04 04:52:42 +00:00
|
|
|
return update_internal_user_password($user, $newpassword);
|
|
|
|
}
|
|
|
|
|
2009-11-23 21:50:40 +00:00
|
|
|
function prevent_local_passwords() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-04 04:52:42 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this authentication plugin is 'internal'.
|
|
|
|
*
|
2007-02-20 17:03:36 +00:00
|
|
|
* @return bool
|
2007-01-04 04:52:42 +00:00
|
|
|
*/
|
|
|
|
function is_internal() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if this authentication plugin can change the user's
|
|
|
|
* password.
|
|
|
|
*
|
2007-02-20 17:03:36 +00:00
|
|
|
* @return bool
|
2007-01-04 04:52:42 +00:00
|
|
|
*/
|
|
|
|
function can_change_password() {
|
|
|
|
return true;
|
|
|
|
}
|
2007-02-20 17:03:36 +00:00
|
|
|
|
2007-01-04 04:52:42 +00:00
|
|
|
/**
|
2007-02-21 21:42:10 +00:00
|
|
|
* Returns the URL for changing the user's pw, or empty if the default can
|
2007-01-04 04:52:42 +00:00
|
|
|
* be used.
|
|
|
|
*
|
2010-08-18 22:07:00 +00:00
|
|
|
* @return moodle_url
|
2007-01-04 04:52:42 +00:00
|
|
|
*/
|
|
|
|
function change_password_url() {
|
2010-08-18 22:07:00 +00:00
|
|
|
return null;
|
2007-02-21 21:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if plugin allows resetting of internal password.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function can_reset_password() {
|
|
|
|
return true;
|
2007-01-04 04:52:42 +00:00
|
|
|
}
|
2007-02-20 17:03:36 +00:00
|
|
|
|
2007-01-04 04:52:42 +00:00
|
|
|
/**
|
|
|
|
* Prints a form for configuring this authentication plugin.
|
|
|
|
*
|
|
|
|
* This function is called from admin/auth.php, and outputs a full page with
|
|
|
|
* a form for configuring this plugin.
|
|
|
|
*
|
|
|
|
* @param array $page An object containing all the data for this page.
|
|
|
|
*/
|
2007-02-20 17:03:36 +00:00
|
|
|
function config_form($config, $err, $user_fields) {
|
2007-01-04 04:52:42 +00:00
|
|
|
include "config.html";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes and stores configuration data for this authentication plugin.
|
|
|
|
*/
|
|
|
|
function process_config($config) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-11-01 11:55:14 +00:00
|
|
|
|