Must The Site Be Needed

I am trying to create my own login page for my webapp.

I created AdminRecord model which is responsible for admin record storage and login/logout action.

I copy the login function from LoginForm model to AdminRecord and the actionLogin of SiteController to AdminRecordController.

Also copied the login form from site. After I changed the login button from site/login to adminRecord/login it was still not working, redirected to site/login again. What I have missed to change?

I suppose you want two separate logins?

This is how I do it:

In ‘components’ array (see config) I have




'user' => array(

    // enable cookie-based authentication

    'class' => 'WebUser',

    'allowAutoLogin' => true,

    'identityCookie' => array(

        'domain' => ...,

    ),

    'loginUrl' => '/login',

    'stateKeyPrefix' => 'user_',

),

'adminUser' => array(

    'class' => 'WebAdmin',

    'allowAutoLogin' => true,

    'identityCookie' => array(

        'domain' => ...,

    ),

    'loginUrl' => '/admin/site/login',

    'stateKeyPrefix' => 'admin_',

),



and in my AdminModule.php in function init() I have this:


Yii::app()->setComponent('user', Yii::app()->adminUser);

WebUser and WebAdmin are subclasses of CWebUser (you probably don’t need them).

PS. If you only need to change the URL, without separation of logins, you can just change ‘loginUrl’ param in user component config.

Thank you. But this is not really what I want. I want a customize login to replace the login that generated by Yiic. And I just want to use my own AdminRecord model for the login action instead of the LoginForm model. But when I try to go to the customize login page which URL is adminRecord/login, it redirects me to the the original one (site/login). This makes me confused.

See PS in my previous message :)




'user' => array(

    'loginUrl' => 'adminRecord/login',

),