Hello,
I'm a newbee in cakephp and I have a little problem with my
administration
access.
I've created a route /admin to have access to all my administration
pages
with a login/password.
The route /admin works nice, I'm automatically redirected to my
login/password connection but when I try to connect me, I received the
message "you don't have access to this page". Normally after my login,
I'ld
be automatically redirected to my page promo.
Therefore I've created a database user with one user "administrator",
with sha1 and security salt.
Please find hereunder the different concerned controllers or views.
users_controller.php
<?php
class UsersController extends AppController
{
var $name = 'Users';
function login(){
$this->layout = 'admin_default';
$this->set('title', 'Administration connexion');
}
function logout(){
$this->Session->setFlash("Vous êtes maintenant déconnecté.");
$this->redirect($this->Auth->logout());
}
}
?>
promos_controller.php
<?php
class PromosController extends AppController {
var $name="Promos";
function index() {
$liste_des_promos = $this->Promo->find('all');
$this->set('promos', $liste_des_promos);
$this->set('title', 'promotions');
}
function admin_index(){
$promosRecents = $this->Promo->find('all');
$this->set('promosRecents', $promosRecents);
}
}
?>
app_controller.php
<?php
class AppController extends Controller
{
var $helpers = array ('Html', 'Text', 'Form');
var $components = array('Auth');
function beforeFilter()
{
if(isset($this->Auth))
{
$this->Auth->userModel = 'User';
$this->Auth->fields = array('username' => 'login', 'password' =>
'password');
$this->Auth->userScope = array('User.disabled' => 0);
$this->Auth->loginAction = '/users/login';
$this->Auth->loginRedirect = '/admin/promos';
$this->Auth->loginError = "username or password not correct";
$this->Auth->logoutRedirect = '/';
$this->Auth->authError = "You don't have access to this page.";
$this->Auth->autoRedirect = true;
$this->Auth->authorize = 'controller';
if((empty($this->params['prefix']) || $this->params['prefix'] !=
'admin') && $this->action != 'login')
{
$this->Auth->allow();
}
}
}
function isAuthorized()
{
return true;
}
function beforeRender()
{
if(isset($this->params['prefix']) && $this->params['prefix'] ==
'admin')
{
$this->layout = 'admin_default';
}
}
}
?>
the routes:
Router::connect('/admin', array('controller' => 'promos', 'action' =>
'index', 'prefix' => 'admin'));
Router::connect('/login', array('controller' => 'users', 'action' =>
'login'));
Do you have an idea where my problem could be?
I think that it's maybe a problem with the permission but where?
Thanks a lot for your help
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---