yii blog tutorial login question

Hello,

It may have been asked already but I can’t find it in the forums so here goes,

when reading the blog tutorial you com across this:


	public function authenticate($attribute,$params)

	{


			$identity=new MUserIdentity($this->username,$this->password);

			$identity->authenticate();

			switch($this->errorCode = $identity->errorCode)

			{

				case MUserIdentity::ERROR_NONE:

					$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days

					Yii::app()->user->login($identity,$duration);

					break;

			        case MUserIdentity::USER_TO_BE_REGISTERED:

 					break;

				default: // UserIdentity::ERROR_PASSWORD_INVALID

					$this->addError('password','Password is incorrect.');

					break;

			}

		}

	}

i don’t understand this: public function authenticate($attribute,$params)

well actually i do know it’s a function and that values are being given to the code within but, what values and why in the other files can’t i see anything that is given to it? at a certain point i just see ->authenticate(); and nothing else…

plz help me,

Tim.

The rules() method in LoginForm.php defines authenticate as custom validation method for the attribute password. These methods are called with the name of the attribute that should be validated and its value. See here for a more detailled explanation:

http://www.yiiframework.com/doc/guide/form.model