You cannot serialize or unserialize PDO instances
- Reka
- Member | 19
Hello,
I am unable to understand what is something wrong with my authentification script.
I have followed this documentation,
but it returns the same error whatever I do, for the line
$user->login($username, $password);
.
The error is : “PDOException – You cannot serialize or unserialize PDO
instances”
Here is my whole code :
Furthermore, I changed the table name and column name under app/model/UserManager (adaptation to my DB reality), but it still go wrong.
Initially, I did all the work by myself (the reason why my code seems """a little bit""" redundant), but if I want to use Oauth and social network connexion it will be complicated. I try to understand the simple way suggested by Nette, but it is more difficult than I thought.
Could you help me, please ?
Thanks in advance.
Last edited by Reka (2015-12-06 21:38)
- Reka
- Member | 19
Hello Greeny,
Where? which line is concerned?
Like this? :/ (completely unsure to understand you…) :
Result : Recoverable Error – Argument 1 passed to iterator_to_array() must implement interface Traversable, instance of Nette\Security\User given
I didn't read that kind of code in other examples :
Garry
or Paolo
- Reka
- Member | 19
I haven't touched a thing somewhere else (views, controllers, the first lines in the model UserManager are the only files I modify)…
About the exception : when I browse the folder, I find
vendor/security/src/security/AuthentificationException.
This file contents :
And I don't find \Exception anywhere…
Where is it supposed to be?
I will generate another Nette project and test its behaviour + see if its
structure is the same.
It was not the case between the first (20/11/2015) and second project
(02/12/2015) I created with composer…
Last edited by Reka (2015-12-09 18:50)
- esorimer
- Member | 114
It seems to me that you have put PDO instance into session somewhere (or object with PDO instance reference …). So the problem is not in the code shown here and will not be possible to find out from the tracy “scary red page”.
You should look for a code, where you are playing with session.
- Reka
- Member | 19
greeny wrote:
I did not mean the exception file, but the error page one. You can find it in log/**, probably the latest one. You can open it in browser (its HTML), but also copy-paste to some service like jsfiddle. Please do so, we can then more deeply investigate the problem :)
Ok, ok… Hum.
So. Under /log/** I have 2 files : .htaccess and web.config.
No HTML file in that folder. A good start, is it so?
Here is the code beyond the error page : https://pastee.org/m8c33
It seems that Esorimer is right about sessions, but I don't know where
I use sessions… I have only 2 controllers at this stage of the project, and
I haven't used that in my controllers or views.
Furthermore, the only model I have is UserManager (see above).
Is it possible that the sessions come from a vendor I have loaded… ?
Thanks again for your perseverance in helping me.
Last edited by Reka (2015-12-09 20:40)
- greeny
- Member | 405
That paste helped, thanks.
Error is in your Authenticator on last lane of authenticate method
(return new Nette\Security\Identity($row[self::COLUMN_ID], $row[self::COLUMN_ROLE], $arr);
)
First and last arguments are ok, but the middle one is not just value. You
are using table roles
, so in $row[self::COLUMN_ROLE]
is ActiveRow
. Possible fix is, that you replace
$row[self::COLUMN_ROLE]
with
$row[self::COLUMN_ROLE]->name
(instead of name
use
the name of column in table roles
where is name for
that role).
<ot> @esorimer it was exactly what I thought </ot>