]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11026 private user key - implement ip restrictions
authorskodak <skodak>
Wed, 29 Aug 2007 18:06:18 +0000 (18:06 +0000)
committerskodak <skodak>
Wed, 29 Aug 2007 18:06:18 +0000 (18:06 +0000)
lib/moodlelib.php

index a1996003bb196e82d2222c8dc3cb89e3f5f11950..071fdac154217ccf882532eb9ea79db914fb4927 100644 (file)
@@ -1907,8 +1907,11 @@ function require_user_key_login($script, $instance=null) {
         error('Expired key');
     }
 
-    if (false) { // TODO
-        error('Client IP mismatch');
+    if ($key->iprestriction) {
+        $remoteaddr = getremoteaddr();
+        if ($remoteaddr == '' or !address_in_subnet($remoteaddr, $key->iprestriction)) {
+            error('Client IP address mismatch');
+        }
     }
 
     if (!$user = get_record('user', 'id', $key->userid)) {