Yubico / php-u2flib-server

(OBSOLETE) U2F library in PHP
https://developers.yubico.com/php-u2flib-server/
BSD 2-Clause "Simplified" License
289 stars 68 forks source link

Counter won't be updated correctly in PDO example #42

Closed paul999 closed 8 years ago

paul999 commented 8 years ago

The counter field in the table won't be updated correctly in the PDO example. https://github.com/Yubico/php-u2flib-server/blob/master/examples/pdo/index.php#L82 this line uses $reg->id, however this doesn't exists within Registration. Due to that, the counter will never be updated and will be kept on 0.

klali commented 8 years ago

Since the registration object in the example is never marshalled into a Registration the id should still be there from the database (admittedly this is fragile).

Have you tried this and observed it not working?

paul999 commented 8 years ago

Yeah, you are right (I discovered it just after I posted the issue), however this is really a bad way of doing that :). I my own application I made for now a extended version of Registration, which actually includes the ID in my code, and use that to pass around. I would also suggest to have in the main API a check for instanceof Register, instead of using is_object to see if it is a object. You expect a Register object, and not a random object (Like currently a stdClass in case of the PDO example).