Fixed wrong handling of nickname in member login
authorRoland Häder <roland@mxchange.org>
Sun, 1 Aug 2010 07:27:18 +0000 (07:27 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 1 Aug 2010 07:27:18 +0000 (07:27 +0000)
inc/libs/user_functions.php
inc/modules/guest/what-login.php
inc/mysql-manager.php
inc/wrapper-functions.php

index fd7ac7740d50a6526bbd8ccddeb823b550c88c86..b4fefbb35d5de0499468da2f06fac8c2b8f7652f 100644 (file)
@@ -276,6 +276,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
        $add = '';
        $errorCode = '0';
        $ext = '';
+       $isFound = false;
 
        // Init array
        $content = array(
@@ -296,11 +297,11 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
                $ext = 'nickname';
        } else {
                // Direct userid entered
-               fetchUserData($userid);
+               $isFound = fetchUserData($userid);
        }
 
        // No error found?
-       if ($errorCode == '0') {
+       if (($errorCode == '0') && ($isFound === true)) {
                // Get user data array and set userid (e.g. important if we login with nickname)
                $content = getUserDataArray();
                if (!empty($content['userid'])) $userid = bigintval($content['userid']);
index e888b2cbbb076e89571c46c7ea2043a801b36b43..f2c6938e8784ff7a0e76f501174082d67fb3c797 100644 (file)
@@ -64,7 +64,7 @@ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
        $userid = getMemberId();
 } elseif ((isPostRequestParameterSet('id')) && (isPostRequestParameterSet('password')) && (isFormSent())) {
        // Set userid and crypt password when login data was submitted
-       if ((isExtensionActive('nickname')) && (isNicknameUsed(postRequestParameter('id')))) {
+       if (isExtensionActive('nickname')) {
                // Nickname entered
                $userid = SQL_ESCAPE(postRequestParameter('id'));
        } else {
@@ -74,7 +74,16 @@ if ((isMemberIdSet()) && (isSessionVariableSet('u_hash'))) {
 } elseif (isPostRequestParameterSet('new_pass')) {
        // New password requested
        $userid = '0';
-       if ((isPostRequestParameterSet('id')) && (postRequestParameter('id') > 0)) $userid = bigintval(postRequestParameter('id'));
+       if (isPostRequestParameterSet('id')) {
+               // Do we have nickname or userid?
+               if ((isExtensionActive('nickname')) && (isNicknameUsed(postRequestParameter('id')))) {
+                       // Nickname entered
+                       $userid = SQL_ESCAPE(postRequestParameter('id'));
+               } else {
+                       // Direct userid entered
+                       $userid  = bigintval(postRequestParameter('id'));
+               }
+       } // END - if
 } else {
        // Not logged in
        $userid = '0'; $hash = '';
index b2083285c0abf408f78975e0a718587d06865ee3..8fadc7f8839f9effbf0c251c10cf632b34ac35e1 100644 (file)
@@ -716,7 +716,7 @@ function getActionFromModuleWhat ($module, $what) {
        // Init status
        $data['action'] = '';
 
-       //* DEBUG: */ debugOutput(__LINE__.'='.$module.'/'.$what.'/'.getAction().'=');
+       //* DEBUG: */ debugOutput(__LINE__ . '=' . $module . '/'.$what . '/' . getAction() . '=');
        if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
                // sql_patches is missing so choose depending on mode
                if (isWhatSet()) {
index e568da44e2658b592d23434a043d680212fdfadd..c6d6d4b1d82243f527530944c780c189510361c5 100644 (file)
@@ -824,8 +824,11 @@ function getUserDataArray () {
        // Get user id
        $uid = getCurrentUserId();
 
-       // User id should not be zero
-       if ($uid < 1) debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       // Is the current userid valid?
+       if (!isValidUserId($uid)) {
+               // Should be always valid
+               debug_report_bug(__FUNCTION__, __LINE__, 'User id is zero.');
+       } // END - if
 
        // Get the whole array if found
        if (isset($GLOBALS['user_data'][$uid])) {