mirror of
https://github.com/SREd-URV/moodle-auth_ip.git
synced 2026-05-16 21:41:30 +02:00
Modify auth.php IP eval
Currently the plugin only gets the users IP form REMOTE_ADDR wich is not an entirely reliable source. a much better source would be the getremoteaddr() function since this is the one moodle uses in the reports. This also prevents issues wen moodle is implemented behind a load balancer. I tested the change in my server and it works like a charm
This commit is contained in:
2
auth.php
2
auth.php
@@ -55,7 +55,7 @@ class auth_plugin_ip extends auth_plugin_manual {
|
||||
global $DB, $CFG;
|
||||
if (($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id)))) {
|
||||
// Check if IP is one of the restricted ones.
|
||||
$userIp = filter_input(INPUT_SERVER, 'REMOTE_ADDR');
|
||||
$userIp = getremoteaddr();
|
||||
|
||||
if (isset($userIp) && $this->is_ip_valid($userIp)) {
|
||||
return validate_internal_user_password($user, $password);
|
||||
|
||||
Reference in New Issue
Block a user