The SitePoint PHP blog continues their series looking at authentication and authorization in a Symfony2 application with part two of their series. This time author Taylor Ren focuses on the registration and login systems for your users.
In part 1, we discussed the basics of setting up a security system in our app (database and security.yml settings). We also covered the pre-registration stage where a user verifies their invitation status with the app. In this article, we will talk about registration, logins and post-login actions.
He starts with the registration side of things, showing how to create a simple form asking for a username, password (and confirming it), a homepage URL and email address. He shows how to link it to a User instance and render the form out to a Twig template. Once the request is submitted the user is created, including encoding (bcrypt) of the password. Next up is the login form that's linked to the "AuthenticationSuccessHandler" for post-success handling. The tutorial finishes off with a piece of code showing how to redirect the user back to their requested URL once authenticated.
Link: http://www.sitepoint.com/symfony2-registration-login/
没有评论:
发表评论