Passing error message for unauthorised user in the fancy box
i have used this controller code: public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->Session->write('group_id', $this->Auth->user("group_id"));
$this->Session->write('username', $this->Auth->user("username"));
$this->Session->write('user_id', $this->Auth->user("user_id"));
//return $this->redirect($this->Auth->redirect());
if ( $this->Auth->user() && $this->Auth->user('group_id') == 1 )
{
//$this->Auth->allowedActions =
array($canAccess[0]['Acl']['action']);
$this->redirect('../users/admin_index');
}
else if ( $this->Auth->user() && $this->Auth->user('group_id')
== 2 ){
//$this->Auth->allowedActions =
array($canAccess[1]['Acl']['action']);
$this->redirect('../portal');
}
} else {
$this->Session->setFlash('username and password is invalid');
//$this->redirect($this->Auth->loginAction);
}
}
}
in my view i created an element and echoed it in the page i want it to
appear.i am getting the exact fancy box when clicked upon the content and
if my login is successful then it is redirecting to the correct page but
if the credentials are wrong it is taking me to my element page and
showing me invalid user name and password .but what exactly i want is that
this error message should appear in my fancy box only .
No comments:
Post a Comment