I have started using Yii framework and I have a -newbie- question about the use of the UserIdentity component.
My application has a admin module, which will act as a backoffice for content showed into the real site. This module has its own table for admins tbl_admin_user.
I want to separate the login method (to check against that table instead of tbl_user) of the module from the one of the general site. For that, I have assumed that I need to implement the authenticate method of UserIdentity just for the module and not the full app, correct my if I’m wrong.
When I override that method, I get nothing. The admin module is using the UserIdentity located at the *protected\components* instead of its own.
Any suggestion?
You must not import your module identification class.
To do so, simply modify your init function in your module class extending CWebModule as below :
Thus, all your module components (and models also) will be imported, i.e. your module identification class.
Take care : doing so, you have 2 imported classes with the same name UserIdentity.
If your application is well configured, the module one must take precedence while in the module because of the position of its directory in the include_path.
But you should give another name to your class extending CUserIdentity in your module, e.g. AdminUserIdentity. Then in your login action, you use new AdminUserIdentity($username,$password) instead of new UserIdentity($username,$password). This will make your code cleaner.