Hi All,
I'm using CakePHP , CAS for Authentication and ACL for Authorization. If the user donot have permission to view the page, i need to flash a message stating Not permitted OR redirect to another page.
Ex: If the user is viewing /users/view/1 .Now the user requests /users/delete/1. The user donot have permission to delete. So I want to display a flash message on the page he requested from (/users/view/1).
In my app_controller, i have the following function:
function beforeFilter() {
$this->__initPhpCas();
if (isset($_SESSION['loggedIn'])){
if(!$this->Acl->check(.....){
//User do not have permission to view the page.
// Need to cancel this request and flash a message
}
}
Any suggestions are appreciated
Final answer is
function beforeFilter() {
$this->__initPhpCas();
if (isset($_SESSION['loggedIn'])){
if(!$this->Acl->check(.....){
//User do not have permission to view the page.
// Need to cancel this request and flash a message
$this->Session->setFlash(__('You are not authorized to view this page.', true));
$this->redirect($_SERVER['HTTP_REFERER']);
}
}