Hi,
can u please explain that is it possible to have more than one UserIdentity.php file in our application?
Thanks in Advance.
With Regards,
Janvi
Hi,
can u please explain that is it possible to have more than one UserIdentity.php file in our application?
Thanks in Advance.
With Regards,
Janvi
Usually you have something like this in your LoginForm.php:
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute,$params)
{
$this->_identity=new UserIdentity($this->username,$this->password);
if(!$this->_identity->authenticate())
$this->addError('password','Incorrect username or password.');
}
You can create your own class that extends CUserIdentity and use it here (instead of ‘new UserIdentity()’) to process user authentication (and other class that extends CUserIdentity as well and use it in different place or whatever).
HI Bizley Sir,
Thanks .
Thanks a lot for answer with example.
As already mentioned, of course you can have more than one UserIdentity class.
That’s the whole point of having a separate UserIdentity class. See this elaborated in the relevant section of the official guide.