Hi all, I've gone over this and re-wrote my Controller three times now. I'm looking for a best practice suggestion.
My Coldsping managed, Service Layer pattern MVC app uses a Controller that listens for a login action. The login form uses username/password pair and I want to get into the habit of validating input prior to authenticating the login credentials. In the spirit of keeping a Controller primarily logic free, I originally requested a userId from my UserService passing in the form variables. If the return value was not 0, I hit the Service again for a User instance and then pass the instance on for the view to use. Using this method, I could provide a response that the login is bad (0), but not if the required form input is valid. After that, I tried having my UserService return either an object or an array of errors (yikes!). Now, I'm validating the form variables in the Controller prior to passing them to the UserService and it still feels fishy to me. What if I ask the service for a User object, set the username and password, then ask the object to validate the input? If the input is valid, I send the object back the Service for authentication. If authenticated, carry on. If not authenticated, prepare an error message and pass error to view for display. I'm modifying Illudium PU-36 generated CFCs for my model (stripping down the validate() method into validatelogin()). Also, I plan to roll js validation on the front end as well, but I want implement server side validation first. Paul Marcotte BCJobs.ca phone: (604) 684-5627 ext. 223 e-mail: [EMAIL PROTECTED] You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
