Hello there,
I'm trying to implement a double entry authentication. But I have some
problems. I am on my login page, and when I login, nothing happen.
I don't know why, I am a beginner with CakePHP.
Any idea ?
<?php
// app/controllers/components/app_auth.php
App::import('Component', 'Auth');
class AppAuthComponent extends AuthComponent
{
/**
* default Configuration
*
* @var array
*/
var $defaults = array(
'userModel' => 'User',
'userScope' => array(),
'fields' => null,
'loginAction' => null,
'loginRedirect' => null,
'logoutRedirect' => null,
'autoRedirect' => true,
'loginError' => "Identifiant ou mot de passe incorrects.",
'authError' => "Vous n'avez pas accès à cette page.",
'flashElement' => 'default',
);
/**
* configuration which depends on the prefix
*
* @var array
*/
var $configs = array(
'students' => array(
'userModel' => 'Student',
'userScope' => null,
'fields' => array('username' => 'loginstudent',
'password'
=> 'passwordstudent'),
'loginAction' => array('controller' => 'students',
'action' =>
'login', 'students' => false),
'loginRedirect' => array('controller' => 'students',
'action' =>
'home'),
'logoutRedirect' => array('controller' => 'students',
'action' =>
'login'),
'flashElement' => 'public_notice',
),
'tutors' => array(
'userModel' => 'Tutor',
'userScope' => null,
'fields' => array('username' => 'logintutor',
'password' =>
'passwordtutor'),
'loginAction' => array('controller' => 'tutors',
'action' =>
'login', 'tutors' => false),
'loginRedirect' => array('controller' => 'tutors',
'action' =>
'home', 'tutors' => true),
'logoutRedirect' => array('controller' => 'tutors',
'action' =>
'login', 'tutors' => false),
'flashElement' => 'public_notice',
),
);
/**
* Démarrage du composant.
* Authorization if no prefix in the route that led here
*
* @param object $controller Le contrôleur qui a appelé le composant.
*/
function startup(&$controller)
{
$prefix = null;
if(empty($controller->params['prefix']))
{
$this->allow();
}
else
{
$prefix = $controller->params['prefix'];
}
// Special case of login and logout actions, for which the
prefix
does not exist
if(in_array($controller->action, array('login', 'logout')))
{
switch($controller->name)
{
case 'tutor':
$prefix = 'tutors';
break;
case 'student':
$prefix = 'students';
break;
}
}
$this->_setup($prefix);
parent::startup($controller);
}
/**
* Config definition of variables based on a prefix
*
* @param string $prefix
*/
function _setup($prefix)
{
$settings = $this->defaults;
if(array_key_exists($prefix, $this->configs))
{
$settings = array_merge($settings,
$this->configs[$prefix]);
}
$this->_set($settings);
}
}
?>
Regards.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php