Reputation: 801
I'm a newbie to cakephp.. I have started it directly from 3.0
I have followed the BLOG tutorial 1,2 and am facing an error in the Blog Tutorial - Authentication and Authorization
// src/Controller/UsersController.php
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Allow users to register and logout.
// You should not add the "login" action to allow list. Doing so would
// cause problems with normal functioning of AuthComponent.
$this->Auth->allow(['add', 'logout']);
}
I'm getting the error when i try to access the /users/add page.
Error: Call to a member function allow() on a non-object
File : src\Controller\UsersController.php
What is wrong? Isn't it supposed to allow to add users without authentication?
Upvotes: 1
Views: 1003
Reputation: 3807
Make sure that the Auth Component
is correctly loaded in your AppController.php
file.
Upvotes: 1
Reputation: 9614
Make sure you call parent::initialize()
in your UsersController.php if you implement the public initialize()
method
Upvotes: 1