I'm not following how somebody would ever log in again without logging
out first.
My login code looks like:
/**
* Login function - this is where we do the login ...
*/
function login() {
if ($this->Auth->user())
{
$auth_user = $this->Auth->user();
$this->set('auth_user',$auth_user);
$this->Session->SetFlash(__('Successfully logged in as '.
$auth_user['User']['full_name'],true));
$this->redirect($this->Auth->redirect());
}
}
If the user needs to be logged in, they click a link that takes them
to users/login, which validates the login.
If they somehow then go to users/login again (by typing the URL, back
arrow, whatever), they get redirected to the same page where they
originally clicked the login button.
The redirect works even without the Auth loginRedirect set. Here's the
beforeFilter I have in my app_controller:
/*
* Set up the Auth component so that we get redirected if we try to
* go to a page that isn't open.
*
*/
function beforeFilter(){
//Configure AuthComponent
$this->Auth->authorize = 'actions';
$this->Auth->loginAction = array(
'admin' => false,
'prefix' => false,
'plugin' => null,
'controller' => 'users',
'action' => 'login'
);
$this->Auth->loginError = 'Invalid user name / password
combination';
$this->Auth->actionPath = 'controllers/';
$this->Auth->fields = array('username' => 'user_name',
'password' => 'user_password');
$this->Auth->allowedActions = array('display');
}
On Dec 4, 1:39 am, krishna <[EMAIL PROTECTED]> wrote:
> I got 2 suggestions for this issue.
>
> 1. Set the session security level to high, so that the session clears
> away after some time, even
> though the user does not logs off.
> 2. Or else, set a redirect code in login method in users controller to
> redirect
> the logged in user(by checking auth user array) to the home page or
> profile page like,
>
> if($this->Auth->user('id')){
> $this->redirect('/')l
>
> }
>
> Regards,
> Krishnan Nair.
> ==================
>
> CakeBake
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---