How To Have Yii Redirect To A Different Login Page

Hi

I have 2 different types of users, they have their own separate DB tables and are logged in entirely separately and currently I have some specific actions that only for one set of users.

How do I enable it so that when they are not logged in Yii redirects them to their correct login page and not the default login one?

Thanks

Jonathon

Maybe I dident get you right, but how does your app know their correct login-page if they are not yet logged in?

Normally in your login controller, after authentication the app will redirect to something like


Yii::app()->user->returnUrl

.

This URL is the url of the page that the user was trying to view when he had to login.

Search for "returnUrl", determine which url the user should go to and use an "if" statement to redirect to the required url instead.


$this->redirect(array('yourController/yourAction'));

I probably didn’t explain it well enough. Say I have two types of users “buyers” and “sellers”.

I have a link on my nav bar that is "list item" only a "seller" would need this link and it needs to be accessed by logged in people. When I click it as a non-logged in person it takes me to my default login system which is for "buyers", what I need to do is make the webapp take me to an alternative login page.

Hope that makes it clearer, sorry for any confusion.

okey.

Can you start a actions (or even the controller if its just for sellers) for only sellers with:




if(Yii::app()->user->isGuest)

{

    $this->redirect(array('site/sellerslogin'));

}



Ofc this makes it hard to use the accessRules, so maybe deniedCallback is an option:

http://www.yiiframework.com/doc/api/1.1/CAccessRule#deniedCallback-detail

Thanks for that