jeremykendall / slim-auth

Authorization and authentication for the Slim Framework using ZF2 Authentication and Acl components
MIT License
244 stars 38 forks source link

Cannot use object of type stdClass as array #13

Closed LorenzBischof closed 9 years ago

LorenzBischof commented 9 years ago

Hello,

I am receiving following error:

127.0.0.1:52605 [200]: /login - Cannot use object of type stdClass as array in /.../vendor/jeremykendall/slim-auth/src/JeremyKendall/Slim/Auth/Adapter/Db/PdoAdapter.php on line 90

I am using following code:

$adapter = new PdoAdapter(
    $db, 
    'Students', 
    'email', 
    'password', 
    new PasswordValidator()
);

$acl = new \Mini\Acl();
$authBootstrap = new Bootstrap($app, $adapter, $acl);
$authBootstrap->bootstrap();
$app->add(new \Slim\Middleware\SessionCookie());

I also added the cookies config and example route. Am I doing something wrong?

jeremykendall commented 9 years ago

It seems you have \PDO::ATTR_DEFAULT_FETCH_MODE set to \PDO::FETCH_OBJ rather than \PDO::FETCH_ASSOC (or one of the other fetch modes that includes an associative array).

A quick fix for you might be to choose \PDO::FETCH_LAZY for now, but this is definitely an oversight on my part. I need to set a fetch mode in the PdoAdapter.

Thanks for the bug report.

LorenzBischof commented 9 years ago

Thank you very much!

jeremykendall commented 9 years ago

@Lorenzbi You're welcome!