Guys, I've been working on a project that's required authentication !
I set up the system it's working perfectly, still I have a problem.
My system got Two roles, USER & ADMIN
4 the admin It's okay, he got the full access after login in.
But 4 the user I want to restrict Some actions and allow just few,
like "Commands/index", "Commands/edit" and finally "Commands/
delete".
I already write the code 4 this part , but it's not working ;(
///THE LOGIN ACTION
function login(){
$this->layout = 'login';
$authenticatedUser=$this->Session->read('Auth.User');
if(!empty($authenticatedUser)){
if($authenticatedUser['role']==1){ //1 means it's an ADMIN , 0
for a
simple USER
//$this->Auth->allow('*');
$this->redirect('/admin/commands');
}else{
$this->Auth-
>allow(array('controller'=>'commands','action'=>'index'));
$this->redirect('/commands');
}
}//End IF !EMPTY
/// THE BEFOREFILTER ACTION
function beforeFilter() {
//$this->redirect(array('action' => 'student_login'));
//Configure AuthComponent
$this->Auth->fields =
array('username'=>'email','password'=>'password');
$this->Auth->loginAction = array('controller' => 'users',
'action' => 'login');
$this->Auth->logoutRedirect = array('controller' => 'users',
'action' => 'login');
$this->Auth->loginError = 'Login impossible, E-mail ou Mot de
passe est incorrect!';
$this->Auth->loginRedirect = array('controller' => 'commands',
'action' => 'index');
$this->Auth->authError = 'Vous n\'avez pas de droits pour acceder a
cette section!';
$this->Auth->autoRedirect=false;
$this->Auth->deny('*');
}
Reagards, AbrahamBoray ;)
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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