]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14679 towards authlib conversion
authorskodak <skodak>
Fri, 30 May 2008 20:54:19 +0000 (20:54 +0000)
committerskodak <skodak>
Fri, 30 May 2008 20:54:19 +0000 (20:54 +0000)
17 files changed:
auth/cas/auth.php
auth/db/auth.php
auth/email/auth.php
auth/imap/auth.php
auth/ldap/auth.php
auth/manual/auth.php
auth/nntp/auth.php
auth/none/auth.php
auth/pam/auth.php
auth/pop3/auth.php
auth/radius/auth.php
auth/shibboleth/auth.php
lib/authlib.php
lib/moodlelib.php
login/change_password_form.php
login/index.php
login/index_form.html

index ae6686d155c2b54deb8c021d36c76b15867fee8a..ad7c2109ad4180412edbfeb380e3d0b85596cd2f 100644 (file)
@@ -354,13 +354,13 @@ if ( !is_object($PHPCAS_CLIENT) ) {
      * Function should return all information available. If you are saving
      * this information to moodle user-table you should honor syncronization flags
      *
-     * @param string $username username (with system magic quotes)
+     * @param string $username username
      *
      * @return mixed array with no magic quotes or false on error
      */
     function get_userinfo($username) {
         $textlib = textlib_get_instance();
-        $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->ldapencoding);
+        $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
         $ldapconnection = $this->ldap_connect();
         $attrmap = $this->ldap_attributes();
         $result = array();
index 6797126fc4c01c7349097f440f01e572c262f5f1..d913a0ed9403dbc1f0d31f0bff26315f1fd1ff84 100644 (file)
@@ -145,7 +145,7 @@ class auth_plugin_db extends auth_plugin_base {
      * Reads any other information for a user from external database,
      * then returns it in an array
      *
-     * @param string $username (with system magic quotes)
+     * @param string $username
      *
      * @return array without magic quotes
      */
@@ -154,7 +154,7 @@ class auth_plugin_db extends auth_plugin_base {
         global $CFG;
 
         $textlib = textlib_get_instance();
-        $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->extencoding);
+        $extusername = $textlib->convert($username, 'utf-8', $this->config->extencoding);
 
         $authdb = $this->db_init();
 
index 8806e8b41cae206f0ced1be5369292a001a7d306..602336ba8b9e79dd2adc11decc74c40e717d4ccc 100644 (file)
@@ -40,8 +40,8 @@ class auth_plugin_email extends auth_plugin_base {
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
-        global $CFG;
-        if ($user = get_record('user', 'username', $username, 'mnethostid', $CFG->mnet_localhost_id)) {
+        global $CFG, $DB;
+        if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
             return validate_internal_user_password($user, $password);
         }
         return false;
index c2c3cf0ae69de288a3d7c17cf8ff82fb7001f1af..a8ed884cc96a8adb3d80f8427b3d422ee8eb45c3 100644 (file)
@@ -69,7 +69,7 @@ class auth_plugin_imap extends auth_plugin_base {
             }
 
             error_reporting(0);
-            $connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
+            $connection = imap_open($host, $username, $password, OP_HALFOPEN);
             error_reporting($CFG->debug);
 
             if ($connection) {
index 247c1bb691f1a0c6c853d0775f68289ff83dc6a1..22bb9ec39e30af9ad948407016023fa86428065d 100644 (file)
@@ -156,13 +156,13 @@ class auth_plugin_ldap extends auth_plugin_base {
      * Function should return all information available. If you are saving
      * this information to moodle user-table you should honor syncronization flags
      *
-     * @param string $username username (with system magic quotes)
+     * @param string $username username
      *
      * @return mixed array with no magic quotes or false on error
      */
     function get_userinfo($username) {
         $textlib = textlib_get_instance();
-        $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->ldapencoding);
+        $extusername = $textlib->convert($username, 'utf-8', $this->config->ldapencoding);
 
         $ldapconnection = $this->ldap_connect();
         $attrmap = $this->ldap_attributes();
index a8c469722f7bfb0e85563dc96d4c2696f26a7723..bb80d52b7d3a5cad4da778bfce5a564f63889dd4 100644 (file)
@@ -40,8 +40,8 @@ class auth_plugin_manual extends auth_plugin_base {
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
-        global $CFG;
-        if ($user = get_record('user', 'username', $username, 'mnethostid', $CFG->mnet_localhost_id)) {
+        global $CFG, $DB;
+        if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
             return validate_internal_user_password($user, $password);
         }
         return false;
index da549b915ea8c8ac79ba448ba76e6ee1ec2e8352..27454d4a3f3bc4f9718406b81894e09d4e614048 100644 (file)
@@ -35,8 +35,8 @@ class auth_plugin_nntp extends auth_plugin_base {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username (with system magic quotes)
-     * @param string $password The password (with system magic quotes)
+     * @param string $username The username
+     * @param string $password The password
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -53,7 +53,7 @@ class auth_plugin_nntp extends auth_plugin_base {
             $host = '{' . trim($host) . ':' . $this->config->port . '/nntp}';
 
             error_reporting(0);
-            $connection = imap_open($host, stripslashes($username), stripslashes($password), OP_HALFOPEN);
+            $connection = imap_open($host, $username, $password, OP_HALFOPEN);
             error_reporting($CFG->debug);
 
             if ($connection) {
index 9b2da1e04b14942437d71cd7addb0fc9008b33f1..8914bba3d865b9f7b80623bd350c151f189c74ae 100644 (file)
@@ -40,8 +40,8 @@ class auth_plugin_none extends auth_plugin_base {
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
-        global $CFG;
-        if ($user = get_record('user', 'username', $username, 'mnethostid', $CFG->mnet_localhost_id)) {
+        global $CFG, $DB;
+        if ($user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
             return validate_internal_user_password($user, $password);
         }
         return true;
index 94a179eb299a1c14265a61cab951c737f9693f97..428479a340c008ae73617a5e8baa30b2f9424edc 100644 (file)
@@ -55,8 +55,8 @@ class auth_plugin_pam extends auth_plugin_base {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username (with system magic quotes)
-     * @param string $password The password (with system magic quotes)
+     * @param string $username The username
+     * @param string $password The password
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -68,7 +68,7 @@ class auth_plugin_pam extends auth_plugin_base {
 
         // call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth
         //if (pam_auth($username, $password, &$errormessage)) {
-        if (pam_auth(stripslashes($username), stripslashes($password))) {
+        if (pam_auth($username, $password)) {
             return true;
         }
         else {
index 888b0d62965bcadc788ba7a668406ecf7ade0bf5..a4a66976afc2886391a7b7f3d493bdacf4ee3a62 100644 (file)
@@ -35,8 +35,8 @@ class auth_plugin_pop3 extends auth_plugin_base {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username (with system magic quotes)
-     * @param string $password The password (with system magic quotes)
+     * @param string $username The username
+     * @param string $password The password
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
@@ -70,7 +70,7 @@ class auth_plugin_pop3 extends auth_plugin_base {
             }
 
             error_reporting(0);
-            $connection = imap_open($host, stripslashes($username), stripslashes($password));
+            $connection = imap_open($host, $username, $password);
             error_reporting($CFG->debug);
 
             if ($connection) {
index e01fe2c3d1e31bdf847d75e8d7c9fc598db3629f..4e2dd44edbba92c70ae151593a477f88d767d8e7 100644 (file)
@@ -36,8 +36,8 @@ class auth_plugin_radius extends auth_plugin_base {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username (with system magic quotes)
-     * @param string $password The password (with system magic quotes)
+     * @param string $username The username
+     * @param string $password The password
      * @return bool Authentication success or failure.
      */
     function user_login ($username, $password) {
@@ -50,7 +50,7 @@ class auth_plugin_radius extends auth_plugin_base {
         // printf("nasport: $this->config->nasport <br/>");
         // printf("secret: $this->config->secret <br/>");
 
-        $rauth = new Auth_RADIUS_PAP(stripslashes($username), stripslashes($password));
+        $rauth = new Auth_RADIUS_PAP($username, $password);
         $rauth->addServer($this->config->host, $this->config->nasport, $this->config->secret);
 
         if (!$rauth->start()) {
index 22d850b4cacc5414612bad7984971d57c98a3a55..8ed938150fe083579cc828efb9cef70b215f91f4 100644 (file)
@@ -46,8 +46,8 @@ class auth_plugin_shibboleth extends auth_plugin_base {
      * Returns true if the username and password work and false if they are
      * wrong or don't exist.
      *
-     * @param string $username The username (with system magic quotes)
-     * @param string $password The password (with system magic quotes)
+     * @param string $username The username
+     * @param string $password The password
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
index 01a414a40d0bafaf8f5869c581e639e2c331eefd..5521dbe5ef33c9bfda9b5c57ce790646031fc919 100644 (file)
@@ -260,7 +260,7 @@ class auth_plugin_base {
      * Function should return all information available. If you are saving
      * this information to moodle user-table you should honor syncronization flags
      *
-     * @param string $username username (with system magic quotes)
+     * @param string $username username
      *
      * @return mixed array with no magic quotes or false on error
      */
index 60a4cf97418579c19b7a4156567eb94a40aebc18..4587df3394710ca36388adafdab85984ff97d95f 100644 (file)
@@ -2889,10 +2889,11 @@ function update_user_record($username, $authplugin) {
     return get_complete_user_data('username', $username);
 }
 
+/**
+ * will truncate userinfo as it comes from auth_get_userinfo (from external auth) 
+ * which may have large fields
+ */
 function truncate_userinfo($info) {
-/// will truncate userinfo as it comes from auth_get_userinfo (from external auth)
-/// which may have large fields
-
     // define the limits
     $limit = array(
                     'username'    => 100,
index 7b34e56b5e997ac037dd80c3c4977eb49ada2b19..7e11f1975633e3371335b279a8f2fa2af8548daa 100644 (file)
@@ -47,7 +47,7 @@ class login_change_password_form extends moodleform {
         update_login_count();
 
         // ignore submitted username
-        if (!$user = authenticate_user_login($USER->username, $data['password'])) {
+        if (!$user = authenticate_user_login($USER->username, stripslashes($data['password']))) { // TODO: remove soon
             $errors['password'] = get_string('invalidlogin');
             return $errors;
         }
index 062df4d979427a1c393a90f0500b1d880380725c..ca701c285f262afb5e1ad28ec1532399de811134 100644 (file)
@@ -90,11 +90,11 @@ httpsrequired();
         if ($user) {
             $frm->username = $user->username;
         } else {
-            $frm = data_submitted();
+            $frm = data_submitted(false);
         }
 
     } else {
-        $frm = data_submitted();
+        $frm = data_submitted(false);
     }
 
 /// Check if the user has actually submitted login data to us
index bfed5054f76f40b156ee6b205248ba6e698c8e42..012075adf0e41592bee6a133130aab19dd305da5 100644 (file)
@@ -30,7 +30,7 @@ if ($show_instructions) {
           <div class="loginform">
             <div class="form-label"><label for="username"><?php print_string("username") ?></label></div>
             <div class="form-input">
-              <input type="text" name="username" id="username" size="15" value="<?php p($frm->username, true) ?>" />
+              <input type="text" name="username" id="username" size="15" value="<?php p($frm->username) ?>" />
             </div>
             <div class="clearer"><!-- --></div>
             <div class="form-label"><label for="password"><?php print_string("password") ?></label></div>