sonoton345 Posted August 17, 2009 Share Posted August 17, 2009 I'm doing password validation in one of my model - jobseeker.php - which works fine during registration. The problem is when a user is editing his/her profile, it still does validation for same password (entered password do not match error comes up), is there a way to bypass this if just editing profile and use it only during registration? var $validate = array( 'username' => array( 'unique' => array( 'rule' => array('checkUnique', 'email'), 'message' => 'Email already registered.' ) ), 'password' => array( 'notEmpty' => array( 'rule' => array('minLength', 6), 'required' => true, 'allowEmpty' => false, 'message' => 'Password has to be at least 6 characters long' ), 'password_similar' => array( 'rule' => 'checkPasswords', 'message' => 'Entered passwords do not match' )) ); function checkPasswords($data) { if ($this->data['Jobseeker']['password'] == $this->data['Jobseeker']['password2']) return true; else return false; } Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/ Share on other sites More sharing options...
jcombs_31 Posted August 18, 2009 Share Posted August 18, 2009 Why not just exclude the password data from the edit/update form? Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-900972 Share on other sites More sharing options...
sonoton345 Posted August 18, 2009 Author Share Posted August 18, 2009 Thank you. someone pointed me to a jquery plugin, so instead of doing validation in model I'm doing it in view which solved the problem. Now I have another problem..what could prevent pages that use the database from not loading (the status bar is just stuck) while other pages not using the database are loading perfectly? I wasn't having this problem before till I changed the validation. Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-901171 Share on other sites More sharing options...
jcombs_31 Posted August 18, 2009 Share Posted August 18, 2009 Set your debug value to 2 in the config settings to see if there is an error. I also would advise against validation on the client side. A user can easily bypass validation by turning off javascript. I only think javascript is a solution if you are using ajax, otherwise you are doing things twice. Don't rely on javascript. Again, you can still validate the other fields in the model, just don't pass the password in the $this->data array. Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-901175 Share on other sites More sharing options...
sonoton345 Posted August 18, 2009 Author Share Posted August 18, 2009 thanks. It is actually set to "2" and it's not displaying any error. Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-901213 Share on other sites More sharing options...
sonoton345 Posted August 18, 2009 Author Share Posted August 18, 2009 Again, you can still validate the other fields in the model, just don't pass the password in the $this->data array. I don't understand what you meant here. Are you saying when editing, don't put in the password field? Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-901247 Share on other sites More sharing options...
jcombs_31 Posted August 18, 2009 Share Posted August 18, 2009 Yes, don't you have a separate function for changing passwords? Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-901279 Share on other sites More sharing options...
sonoton345 Posted August 19, 2009 Author Share Posted August 19, 2009 no i don't. that was what i was trying to do in the first place with admin (my other post). if i get that to work then i can use the same method for others. Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-901562 Share on other sites More sharing options...
sonoton345 Posted August 22, 2009 Author Share Posted August 22, 2009 Why not just exclude the password data from the edit/update form? I excluded the password data from the edit form and it's still doing a password form test. Quote Link to comment https://forums.phpfreaks.com/topic/170750-problem-with-same-password-validation-in-cakephp-model/#findComment-904046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.