Jump to content

Problem with same password validation in cakephp model


sonoton345

Recommended Posts

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;

 }

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.