]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
Changed all admin getter, closed internal TODOs:
[mailer.git] / inc / modules / admin / admin-inc.php
index 891d19cfec49742bc32b9a466ca7f9e91afa9f9c..68560831e64a9892585cf086426aecfcbc5e5821 100644 (file)
@@ -77,29 +77,36 @@ function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) {
        // First of all, no admin login is found
        $ret = '404';
 
        // First of all, no admin login is found
        $ret = '404';
 
-       // Then we need to lookup the login name by getting the admin hash
-       $adminHash = getAdminHash($adminLogin);
-
-       // If this is fine, we can continue
-       if ($adminHash != '-1') {
-               // Get admin id and set it as current
-               setCurrentAdminId(getAdminId($adminLogin));
-
-               // Now, we need to encode the password in the same way the one is encoded in database
-               $testHash = generateHash($adminPassword, $adminHash);
-
-               // If they both match, the login data is valid
-               if ($testHash == $adminHash) {
-                       // All fine
-                       $ret = 'done';
-               } else {
-                       // Set status
-                       $ret = 'pass';
-               }
+       // Get admin id from login
+       $adminId = getAdminId($adminLogin);
+
+       // Continue only with found admin ids
+       if ($adminId > 0) {
+               // Then we need to lookup the login name by getting the admin hash
+               $adminHash = getAdminHash($adminId);
+
+               // If this is fine, we can continue
+               if ($adminHash != '-1') {
+                       // Get admin id and set it as current
+                       setCurrentAdminId($adminId);
+
+                       // Now, we need to encode the password in the same way the one is encoded in database
+                       $testHash = generateHash($adminPassword, $adminHash);
+
+                       // If they both match, the login data is valid
+                       if ($testHash == $adminHash) {
+                               // All fine
+                               $ret = 'done';
+                       } else {
+                               // Set status
+                               $ret = 'pass';
+                       }
+               } // END - if
        } // END - if
 
        // Prepare data array
        $data = array(
        } // END - if
 
        // Prepare data array
        $data = array(
+               'id'         => $adminId,
                'login'      => $adminLogin,
                'plain_pass' => $adminPassword,
                'pass_hash'  => $adminHash
                'login'      => $adminLogin,
                'plain_pass' => $adminPassword,
                'pass_hash'  => $adminHash
@@ -161,7 +168,7 @@ function doAdminAction () {
        $action = getActionFromModuleWhat(getModule(), $what);
 
        // Define admin login name and id number
        $action = getActionFromModuleWhat(getModule(), $what);
 
        // Define admin login name and id number
-       $content['login'] = getSession('admin_login');
+       $content['login'] = getAdminLogin(getSession('admin_id'));
        $content['id']    = getCurrentAdminId();
 
        // Preload templates
        $content['id']    = getCurrentAdminId();
 
        // Preload templates