Hi everyone,
In page 159, password encryption functionality is added using CActiveRecord::afterValidate() method. I'm pondering about the alternative way of implementing encryption in UserController::actionCreate().
Besides the educational purpose of showing us the afterValidate() method, what are the pros and cons of both places?
Regards,
Page 1 of 1
password encryption why in User model and not in actionCreate
#2
Posted 10 August 2011 - 07:42 AM
Well, after validate is good place, because you crypt after it passed all validations. Also I like idea of keeping everything related to model in model so this is another reason.
Off course you could encrypt your password in controller, after it pass(if) validation, but I like more solution explained in book.
Off course you could encrypt your password in controller, after it pass(if) validation, but I like more solution explained in book.
Zurmo: Yii Powered Open Source CRM
zurmo.org
zurmo.org
#3
Posted 10 August 2011 - 09:05 AM
It makes sense that the encryption is performed within the model, as how the model encrypts it's passwords is something for the model to encapsulate and not a controller, which is primarily about routing data, to handle. So, for example you may wish to create users in a few places and not have to add the logic to hash the password in each of those places. Might be worth just reading about MVC architecture to remind yourself about the responsibilities of the Models, Views and Controllers.
#4
Posted 30 July 2012 - 05:49 AM
getting this
Use of undefined constant value - assumed 'value'
Use of undefined constant value - assumed 'value'
Good Programming is 99% Sweet and 1% Coffee
#5
Posted 28 September 2012 - 10:10 AM
While it's an energetic romp, there is more slapstick humor than wit at work here
Share this topic:
Page 1 of 1

Help















