Users, Registration, and Authentication If they have submitted the form, we check the registration, to see if the values are valid: if( $this-checkRegistration() == true ) { If the form was completed properly, we can then process the registration and create the user account and the profile: $userId = $this-processRegistration(); if( $this-activeValue == 1 ) { If we have set all users to be active by default, we log the user in automatically: $this-registry-getObject('authenticate')forceLogin( $this-submittedValues['register_ user'], md5( $this-submittedValues['register_ password'] ) ); } $this-uiRegistrationProcessed(); } else { If the registration attempt wasn't successful, we display the user interface, passing a parameter to indicate that errors need to be. | Users Registration and Authentication If they have submitted the form we check the registration to see if the values are valid if this- checkRegistration true If the form was completed properly we can then process the registration and create the user account and the profile userId this- processRegistration if this- activeValue 1 If we have set all users to be active by default we log the user in automatically this- registry- getObject authenticate - forceLogin this- submittedValues register_ user md5 this- submittedValues register_ password this- uiRegistrationProcessed else If the registration attempt wasn t successful we display the user interface passing a parameter to indicate that errors need to be displayed. this- uiRegister true Finally if the user is just viewing the registration form we simply show them that courtesy of the uiRegister method . else this- uiRegister false CAPTCHA We don t want our social network to get clogged up with automated signups that aren t going to add anything to our site. We can use a CAPTCHA Completely Automated Public Turing test to tell Computers and Human Apart challenge to test that the sign up is a genuine person. A CAPTCHA challenge is often a series of words embedded in an image many computer systems can t automatically pick up the text from this image whereas a human can helping to tell which signup is a human and which is an automated computer. ------------------------------------ 82 ----------------------------------- Download from Wow eBook Chapter 3 General CAPTCHA Generally CAPTCHA systems work by Generating a random phrase or string. Storing this phrase in the user s session so they can t see it but we have a persistent copy as they move from the registration form to process their registration. This is also useful as the image is generally generated by a separate HTTP request so the session is needed to maintain the value . Displaying a slightly distorted version of the phrase on the registration .