You cannot serialize or unserialize PDO instances

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
Muhahe
Člen | 79
+
0
-

Zdravim,

trosku sem si hral s authenticatorem, a nette zaclo hazet chybu You cannot serialize or unserialize PDO instances s odkazem na Call Stack (oznacen radek 425)

415:            $service = new Repositors\UsersRepository($this->getService('nette.database.default'));
416:            return $service;
417:        }
418:
419:
420:        public function initialize()
421:        {
422:            date_default_timezone_set('Europe/Prague');
423:            Nette\Bridges\Framework\TracyBridge::initialize();
424:            Nette\Caching\Storages\FileStorage::$useDirectories = TRUE;
425:            $this->getByType("Nette\Http\Session")->exists() && $this->getByType("Nette\Http\Session")->start();
426:            header('X-Frame-Options: SAMEORIGIN');
427:            header('X-Powered-By: Nette Framework');
428:            header('Content-Type: text/html; charset=utf-8');
429:            Nette\Utils\SafeStream::register();

vratil jsem provedene zmeny zpet a chyby se nemuzu porad zbavit. Mazal jsem nette chache a zkousel restartovat apache.

authenticator

<?php

use Nette\Security as NS;

class Authenticator extends Nette\Object implements NS\IAuthenticator {

    /** @var Nette\Database\Connection */
    public $context;

    public function __construct(Nette\Database\Context $connection) {
        $this->context = $connection;
    }


    public function authenticate(array $credentials) {
        list($username, $password) = $credentials;
        $row = $this->context->table('users')->where('login', $username)->fetch();

        if (!$row) {
            throw new NS\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
        }

        if ($row->password !== md5($password)) {
            throw new NS\AuthenticationException('Invalid password.');
        }

        return new NS\Identity($row->id, $row->roleid, $row->login);
    }

    /**
     * Computes salted password hash.
     * @param  string
     * @return string
     */
    public static function calculateHash($password, $salt = NULL) {
        if ($password === Strings::upper($password)) { // perhaps caps lock is on
            $password = Strings::lower($password);
        }
        return crypt($password, $salt ? : '$2a$07$' . Strings::random(22));
    }

}

Predem dekuji za kazdou radu

David Matějka
Moderator | 6445
+
0
-

mozna se ti do session dostal nejakej bordel. Zkus smazat session (nebo aspon v browseru smaz prirazene PHPSESSID, at se vygeneruje nove.)

Muhahe
Člen | 79
+
0
-

matej21 napsal(a):

mozna se ti do session dostal nejakej bordel. Zkus smazat session (nebo aspon v browseru smaz prirazene PHPSESSID, at se vygeneruje nove.)

Dekuju, funguje jako vino :) a pritom tak jednoduche