У меня есть измененный AppController.php, logins_controller.php и несколько представлений
Для известных пользователей я получаю следующее сообщение об ошибке: Не уверен, почему, поскольку я указываю на правильный контроллер ...Любые предложения?
http://my.ip.address/cakephp/logins/knownusers
Authorization adapter "controller" was not found.
Error: An Internal Error Has Occurred.
Stack Trace
#0 /var/www/cakephp/lib/Cake/Controller/Component/AuthComponent.php(376): AuthComponent->constructAuthorize()
#1 /var/www/cakephp/lib/Cake/Controller/Component/AuthComponent.php(330): AuthComponent->isAuthorized(Array)
#2 [internal function]: AuthComponent->startup(Object(LoginsController))
#3 /var/www/cakephp/lib/Cake/Utility/ObjectCollection.php(103): call_user_func_array(Array, Array)
#4 /var/www/cakephp/lib/Cake/Controller/Controller.php(606): ObjectCollection->trigger('startup', Array)
#5 /var/www/cakephp/lib/Cake/Routing/Dispatcher.php(104): Controller->startupProcess()
#6 /var/www/cakephp/lib/Cake/Routing/Dispatcher.php(89): Dispatcher->_invoke(Object(LoginsController), Object(CakeRequest), Object(CakeResponse))
#7 /var/www/cakephp/app/webroot/index.php(96): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#8 {main}
AppController.php
App::uses('Controller', 'Controller');
/**
* This is a placeholder class.
* Create the same file in app/Controller/AppController.php
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.
*
* @package Cake.Controller
* @link http://book.cakephp.org/view/957/The-App-Controller
*/
class AppController extends Controller {
public $components = array('Auth');
public $helpers = array('Session', 'Html', 'Form', 'Session');
function beforeFilter(){
$this->Auth->loginAction = array('controller' => 'logins', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display', 'home');
$this->Auth->allow('display');
$this->Auth->authorize = 'controller';
$this->set('Auth',$this->Auth);
}
function isAuthorized() {
return true;
}
}
logins_controller.php
<?php
class LoginsController extends AppController {
public $name = 'Logins';
function beforeFilter() {
// tell Auth not to check authentication when doing the 'register' action
parent::beforeFilter();
//$this->Auth->allow('register');
}
function register() {
if (!empty($this->data)){
if ($this->Login->save($this->params['data'])) {
// $this->flash('Your registration information was accepted. Welcome!','/pages/display/home');
$this->Auth->login($this->data);
$this->redirect('/pages/display/home');
} else {
$this->flash('There was a problem with your registration', '/logins/register');
}
}
}
function login() {
if(!empty($this->data)) {
$this->Auth->login($this->data);
$this->redirect('/pages/display/home');
}
}
function logout() {
$this->redirect($this->Auth->logout());
}
}
?>
login.ctp
<h1>User Login Form</h1>
<?php
echo $this->Form->create('Login', array('action'=>'login'));
echo $this->Form->input('username');
echo $this->Form->input('password', array('type'=>'password'));
echo $this->Form->submit();
echo $this->Form->end();
?>
knownusers.ctp
<table>
<?php
echo $this->Html->tableHeaders(array_keys($knownusers[0]['Login']));
foreach ($knownusers as $thisuser)
{
echo $this->Html->tableCells($thisuser['Login']);
}
?>
</table>