If you already have the whole Auth system, why don't you just follow the KISS principle and cancel your password or change your username there? If they can no longer authenticate with your system as before, they should be able to infer that they are denied.
If this is not enough, then you can add the code below.
function login() { if ($this->Session->read('Auth.User')) { $this->Session->setFlash('You are alreadylogged in!~~~~~~~~~~~'); } $this->Session->setFlash('You have been banned!'); $this->redirect(array('controller'=>'users','action'=>'index')); }
Editing 1: for a more dynamic approach, as you pointed out in your comment, you can check the is_banned column of a userβs record of concern in UsersController::beforeFilter() and set the corresponding flash message. Also do a redirect based on the result of $this->Session->read('Auth.User.is_banned') . Perhaps you want to see the result of <?php debug $this->Session->read('Auth.User) ?> Before attacking your problem.
Edit 2: My mistake. You can save is_banned somewhere in the session via $this->Session->write(...) . After you read is_banned = true , you can is_banned = true user.
benjamin
source share