Google analytics code

Friday, June 27, 2014

Zend Framework 2.x Learn ZF2 by Example: Protecting our Pages - Authentication type

I'm starting to implement authentication on my web app and I ran into a problem with the example in the book.

The example on page 146 uses MD5 as a encryption scheme.

$adapter = new DbAdapter($db,
                         'users',
                         'login',
                         'password',
                         'MD5(password)');

The adapter builds a simple SQL query that will check the table, match the user name and password then let you know if it's valid. The problem lies in the 5th parameter. When I tried to match an account I know works it kept saying the account wasn't valid. After digging into the documentation I found the 5th parameter wasn't configured right. It should be 'MD5(?)'.

$adapter = new DbAdapter($db,
                         'users',
                         'login',
                         'password',
                         'MD5(?)');

After the change the auth adapter works perfectly. Hope this helps save you some time.

No comments:

Post a Comment

If you found this page useful, or you have any feedback, please leave a comment.