Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
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.
8
//
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.
13
//
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/>.
16
 
17
/**
18
 * Anobody can login with any password.
19
 *
20
 * @package auth_none
21
 * @author Martin Dougiamas
22
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->libdir.'/authlib.php');
28
 
29
/**
30
 * Plugin for no authentication.
31
 */
32
class auth_plugin_none extends auth_plugin_base {
33
 
34
    /**
35
     * Constructor.
36
     */
37
    public function __construct() {
38
        $this->authtype = 'none';
39
        $this->config = get_config('auth_none');
40
    }
41
 
42
    /**
43
     * Old syntax of class constructor. Deprecated in PHP7.
44
     *
45
     * @deprecated since Moodle 3.1
46
     */
47
    public function auth_plugin_none() {
48
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
49
        self::__construct();
50
    }
51
 
52
    /**
53
     * Returns true if the username and password work or don't exist and false
54
     * if the user exists and the password is wrong.
55
     *
56
     * @param string $username The username
57
     * @param string $password The password
58
     * @return bool Authentication success or failure.
59
     */
60
    function user_login($username, $password) {
61
        global $CFG, $DB;
62
        if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
63
            return validate_internal_user_password($user, $password);
64
        }
65
        return true;
66
    }
67
 
68
    /**
69
     * Updates the user's password.
70
     *
71
     * called when the user password is updated.
72
     *
73
     * @param  object  $user        User table object
74
     * @param  string  $newpassword Plaintext password
75
     * @return boolean result
76
     *
77
     */
78
    function user_update_password($user, $newpassword) {
79
        $user = get_complete_user_data('id', $user->id);
80
        // This will also update the stored hash to the latest algorithm
81
        // if the existing hash is using an out-of-date algorithm (or the
82
        // legacy md5 algorithm).
83
        return update_internal_user_password($user, $newpassword);
84
    }
85
 
86
    function prevent_local_passwords() {
87
        return false;
88
    }
89
 
90
    /**
91
     * Returns true if this authentication plugin is 'internal'.
92
     *
93
     * @return bool
94
     */
95
    function is_internal() {
96
        return true;
97
    }
98
 
99
    /**
100
     * Returns true if this authentication plugin can change the user's
101
     * password.
102
     *
103
     * @return bool
104
     */
105
    function can_change_password() {
106
        return true;
107
    }
108
 
109
    /**
110
     * Returns the URL for changing the user's pw, or empty if the default can
111
     * be used.
112
     *
113
     * @return moodle_url
114
     */
115
    function change_password_url() {
116
        return null;
117
    }
118
 
119
    /**
120
     * Returns true if plugin allows resetting of internal password.
121
     *
122
     * @return bool
123
     */
124
    function can_reset_password() {
125
        return true;
126
    }
127
 
128
    /**
129
     * Returns true if plugin can be manually set.
130
     *
131
     * @return bool
132
     */
133
    function can_be_manually_set() {
134
        return true;
135
    }
136
 
137
}
138
 
139