Changeset:
        02a0f1101714
        
https://sourceforge.net/p/mrbs/hg-code/ci/02a0f110171469572c1acead47b8a0676397d5b0
Author:
        Campbell Morrison <[email protected]>
Date:
        Mon Feb 20 15:09:52 2017 +0000
Log message:

Made authValidateUser() return a boolean instead of 0/1, for consistency

diffstat:

 web/auth/auth_auth_basic.inc |  14 +++++++-------
 web/auth/auth_config.inc     |  11 +++++------
 web/auth/auth_crypt.inc      |  14 +++++++-------
 web/auth/auth_db.inc         |   1 -
 web/auth/auth_db_ext.inc     |  19 +++++++++----------
 web/auth/auth_ext.inc        |  10 +++++-----
 web/auth/auth_imap.inc       |  12 ++++++------
 web/auth/auth_ldap.inc       |  44 ++++++++++++++++++++++----------------------
 web/auth/auth_nis.inc        |  12 ++++++------
 web/auth/auth_none.inc       |   4 ++--
 web/auth/auth_nw.inc         |  12 ++++++------
 web/auth/auth_pop3.inc       |  14 +++++++-------
 web/auth/auth_smtp.inc       |  10 +++++-----
 web/auth/auth_wordpress.inc  |   5 ++---
 14 files changed, 89 insertions(+), 93 deletions(-)

diffs (truncated from 677 to 300 lines):

diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_auth_basic.inc
--- a/web/auth/auth_auth_basic.inc      Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_auth_basic.inc      Mon Feb 20 15:09:52 2017 +0000
@@ -33,8 +33,8 @@
  * $pass  - The password
  * 
  * Returns:
- *   0        - The pair are invalid or do not exist
- *   non-zero - The pair are valid
+ *   false    - The pair are invalid or do not exist
+ *   true     - The pair are valid
  */
 function authValidateUser($user, $pass)
 {
@@ -43,18 +43,18 @@
   // Check if we do not have a username/password
   if(!isset($user) || !isset($pass))
   {
-    return 0;
+    return false;
   }
 
   if (!isset($auth["auth_basic"]["passwd_file"]))
   {
     error_log("auth_basic: passwd file not specified");
-    return 0;
+    return false;
   }
   if (!isset($auth["auth_basic"]["mode"]))
   {
     error_log("auth_basic: mode not specified");
-    return 0;
+    return false;
   }
 
   require_once "File/Passwd/Authbasic.php";
@@ -64,11 +64,11 @@
   $f->setMode($auth["auth_basic"]["mode"]);
   $f->load();
 
-  $ret = 0;
+  $ret = false;
 
   if ($f->verifyPasswd($user, $pass) === true)
   {
-    $ret = 1;
+    $ret = true;
   }
 
   return $ret;
diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_config.inc
--- a/web/auth/auth_config.inc  Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_config.inc  Mon Feb 20 15:09:52 2017 +0000
@@ -26,10 +26,9 @@
  * $pass  - The password
  * 
  * Returns:
- *   0        - The pair are invalid or do not exist
- *   non-zero - The pair are valid
+ *   false    - The pair are invalid or do not exist
+ *   true     - The pair are valid
  */
-
 function authValidateUser($user, $pass)
 {
   global $auth;
@@ -37,7 +36,7 @@
   // Check if we do not have a username/password
   if(!isset($user) || !isset($pass) || strlen($pass)==0)
   {
-    return 0;
+    return false;
   }
 
   if ((isset($auth["user"][$user]) &&
@@ -47,10 +46,10 @@
        ($auth["user"][utf8_strtolower($user)] == $pass)
         ))
   {
-    return 1; // User validated
+    return true; // User validated
   }
 
-  return 0;      // User unknown or password invalid
+  return false;      // User unknown or password invalid
 }
 
 /* authGetUserLevel($user)
diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_crypt.inc
--- a/web/auth/auth_crypt.inc   Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_crypt.inc   Mon Feb 20 15:09:52 2017 +0000
@@ -30,8 +30,8 @@
  * $pass  - The password
  * 
  * Returns:
- *   0        - The pair are invalid or do not exist
- *   non-zero - The pair are valid
+ *   false    - The pair are invalid or do not exist
+ *   true     - The pair are valid
  */
 function authValidateUser($user, $pass)
 {
@@ -40,28 +40,28 @@
   // Check if we do not have a username/password
   if(!isset($user) || !isset($pass))
   {
-    return 0;
+    return false;
   }
 
   if (!isset($auth["crypt"]["passwd_file"]))
   {
     error_log("auth_crypt: passwd file not specified");
-    return 0;
+    return false;
   }
   $fh = fopen($auth["crypt"]["passwd_file"], "r");
   if (!$fh)
   {
     error_log("auth_crypt: couldn't open passwd file\n");
-    return 0;
+    return false;
   }
-  $ret = 0; // Default to failure
+  $ret = false; // Default to failure
   while ($line = fgets($fh))
   {
     if (preg_match("/^\Q$user\E:(.*)/", $line, $matches))
     {
       if (crypt($pass, $matches[1]) == $matches[1])
       {
-        $ret = 1; // Success!
+        $ret = true; // Success!
       }
     }
   }
diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_db.inc
--- a/web/auth/auth_db.inc      Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_db.inc      Mon Feb 20 15:09:52 2017 +0000
@@ -119,7 +119,6 @@
  *   true     - The pair are invalid or do not exist
  *   false    - The pair are valid
  */
-
 function authValidateUser($user, $pass)
 {
   global $tbl_users;
diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_db_ext.inc
--- a/web/auth/auth_db_ext.inc  Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_db_ext.inc  Mon Feb 20 15:09:52 2017 +0000
@@ -43,15 +43,14 @@
  * $pass  - The password
  * 
  * Returns:
- *   0        - The pair are invalid or do not exist
- *   non-zero - The pair are valid
+ *   false    - The pair are invalid or do not exist
+ *   true     - The pair are valid
  */
-
 function authValidateUser($user, $pass)
 {
   global $auth, $db_ext_conn;
 
-  $retval = 0;
+  $retval = false;
 
 
   // syntax_casesensitive_equals() modifies our SQL params array for us.   We 
need an exact match -
@@ -76,21 +75,21 @@
       case 'md5':
         if (md5($pass) == $row[0])
         {
-          $retval = 1;
+          $retval = true;
         }
         break;
 
       case 'sha1':
         if (sha1($pass) == $row[0])
         {
-          $retval = 1;
+          $retval = true;
         }
         break;
 
       case 'sha256':
         if (hash('sha256', $pass) == $row[0])
         {
-          $retval = 1;
+          $retval = true;
         }
         break;
 
@@ -98,14 +97,14 @@
         $recrypt = crypt($pass,$row[0]);
         if ($row[0] == $recrypt)
         {
-          $retval = 1;
+          $retval = true;
         }
         break;
 
       case 'password_hash':
         if (password_verify($pass, $row[0]))
         {
-          $retval = 1;
+          $retval = true;
         }
         break;
 
@@ -120,7 +119,7 @@
 
         if ($pass == $row[0])
         {
-          $retval = 1;
+          $retval = true;
         }
         break;
     }
diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_ext.inc
--- a/web/auth/auth_ext.inc     Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_ext.inc     Mon Feb 20 15:09:52 2017 +0000
@@ -53,8 +53,8 @@
  * $pass  - The password
  * 
  * Returns:
- *   0        - The pair are invalid or do not exist
- *   non-zero - The pair are valid
+ *   false    - The pair are invalid or do not exist
+ *   true     - The pair are valid
  */
 function authValidateUser($user, $pass)
 {
@@ -63,7 +63,7 @@
   // Check if we do not have a username/password
   if(!isset($user) || !isset($pass))
   {
-    return 0;
+    return false;
   }
    
   // Generate the command line
@@ -77,11 +77,11 @@
   // If it succeeded, return success
   if ($ret == 0)
   {
-    return 1;
+    return true;
   }
 
   // return failure
-  return 0;
+  return false;
 }
 
 /* authGetUserLevel($user)
diff -r b5b3919db394 -r 02a0f1101714 web/auth/auth_imap.inc
--- a/web/auth/auth_imap.inc    Mon Feb 20 14:23:59 2017 +0000
+++ b/web/auth/auth_imap.inc    Mon Feb 20 15:09:52 2017 +0000
@@ -45,8 +45,8 @@
  * $pass  - The password
  * 
  * Returns:
- *   0        - The pair are invalid or do not exist
- *   non-zero - The pair are valid
+ *   false    - The pair are invalid or do not exist
+ *   true     - The pair are valid
  */
 function authValidateUser($user, $pass)
 {
@@ -59,7 +59,7 @@
   // Check if we do not have a username/password
   if (!isset($user) || !isset($pass) || strlen($pass)==0)
   {
-    return 0;
+    return false;
   }
 
   // Check that if there is an array of hosts and an array of ports
@@ -68,7 +68,7 @@
       is_array( $imap_port ) &&
       (count($imap_port) != count($imap_host)) )
   {
-    return 0;
+    return false;
   }
 
   // Transfer the list of imap hosts to an new value to ensure that
@@ -117,7 +117,7 @@
         fputs( $stream, "a002 LOGOUT\r\n" );
         $response = fgets( $stream, 1024 );
         fclose( $stream );
-        return 1;
+        return true;
       }
       fputs( $stream, "a002 LOGOUT\r\n" );
       fclose( $stream );
@@ -125,7 +125,7 @@
   }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to