Raised This Month: $ Target: $400
 0% 

Bug Report Login problems using v1.8.0 (php 8.2.4)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ph
AlliedModders Donor
Join Date: Mar 2006
Old 07-23-2023 , 05:51   Login problems using v1.8.0 (php 8.2.4)
Reply With Quote #1

I am unable to login, upgraded to 1.8.0, using php 8.2.4
Can someone help me to fix this login error.

AJAX Call Failed!

Error: the XML response that was returned from the server is invalid. Received:
Fatal error: Uncaught TypeError: Unsupported operand types: string * int in C:\xampp\htdocs\bans3\includes\auth\handler\N ormalAuthHandler.php:14 Stack trace: #0 C:\xampp\htdocs\bans3\includes\sb-callback.php(116): NormalAuthHandler->__construct(Object(Database), 'Johnny ', 'xxxxxxxxxxxxxxx', true) #1 C:\xampp\htdocs\bans3\includes\xajax.inc.php( 1090): Plogin('Johnny', 'xxxxxxxxxxxxxxx', true, '', '0') #2 C:\xampp\htdocs\bans3\includes\xajax.inc.php( 739): xajax->_callFunction('Plogin', Array) #3 C:\xampp\htdocs\bans3\index.php(24): xajax->processRequests() #4 {main} thrown in C:\xampp\htdocs\bans3\includes\auth\handler\N ormalAuthHandler.php on line 14
You have whitespace in your response.


Code:
 <?php

class NormalAuthHandler
{
    private $result = false;

    public function __construct(
        private ?Database $dbs,
        string $username, string $password, bool $remember)
    {
        $this->dbs = $dbs;
        $user = $this->getInfosFromDatabase($username);

        $maxlife = (($remember) ? Config::get('auth.maxlife.remember') : Config::get('auth.maxlife'))*60;

        if (!$user || empty($password))
            return;

        if (!empty($password) && (!empty($user['password']) || !is_null($user['password']))) {
            if ($this->checkPassword($password, $user['password'])) {
                $this->result = true;
                Auth::login($user['aid'], $maxlife);
            } elseif ($this->legacyPasswordCheck($password, $user['password'])) {
                $this->result = true;
                $this->updatePasswordHash($password, $user['aid']);
                Auth::login($user['aid'], $maxlife);
            }
        }
    }

    public function getResult()
    {
        return $this->result;
    }

    private function checkPassword(string $password, string $hash)
    {
        return (bool)(password_verify($password, $hash));
    }

    private function legacyPasswordCheck(string $password, string $hash)
    {
        $crypt = @crypt($password, SB_NEW_SALT);
        $sha1 = @sha1(sha1('SourceBans' . $password));

        return (bool)(hash_equals($crypt, $hash) || hash_equals($sha1, $hash));
    }

    private function updatePasswordHash(string $password, int $aid)
    {
        $this->dbs->query("UPDATE `:prefix_admins` SET password = :password WHERE aid = :aid");
        $this->dbs->bind(':aid', $aid, \PDO::PARAM_INT);
        $this->dbs->bind(':password', password_hash($password, PASSWORD_BCRYPT), \PDO::PARAM_STR);
        $this->dbs->execute();
    }

    private function getInfosFromDatabase(string $username)
    {
        $this->dbs->query("SELECT aid, password FROM `:prefix_admins` WHERE user = :username");
        $this->dbs->bind(':username', $username, \PDO::PARAM_STR);
        return $this->dbs->single();
    }
}



How can I fix this, any solutions.
Attached Thumbnails
Click image for larger version

Name:	IMG_5132.jpg
Views:	274
Size:	14.8 KB
ID:	201194  
__________________

Last edited by ph; 07-23-2023 at 06:15.
ph is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode