AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   SourceBans / SourceBans++ (https://forums.alliedmods.net/forumdisplay.php?f=152)
-   -   Bug Report Login problems using v1.8.0 (php 8.2.4) (https://forums.alliedmods.net/showthread.php?t=343429)

ph 07-23-2023 04:51

Login problems using v1.8.0 (php 8.2.4)
 
1 Attachment(s)
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 https://forums.alliedmods.net/attach...1&d=1690102223the 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.


All times are GMT -4. The time now is 00:22.

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