Hey everyone,
I have a controller which requires people to be logged in. This all works dandy and it will redirect if the user is not logged in.
The problem is that this controller is actually accessed over AJAX and even in AJAX the logged in access rule returns the HTML login page. Returning this HTMl produces errors in my app so I am trying to work out how I can change the default action of the request login rule to send back an error "You need to login" or something when the user tries to do something that they are not logged in to do. I do not necessarily need it to produce some fancy return which will allow for dynamic login there and then, just a dialog which will tell them they need to login and will then redirect when they say "log me in".
I am using pretty much the default access rules with the RBAM extension on top (but since the RBAM just decides rules etc I don’t think I need to go into which RBAM I am using), like so:
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('save', 'delete', 'ajax_validate'),
'roles'=>array('Admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
So I need to know if it is possible (without breaking the upgrade ability of the Yii framework) to change the behaviour of the request login part the admin role in the Yii code.
Thanks,