I have a simple authentication system in place on my Cake website and only allow a user to access the index and view of my posts_controller but they cannot add or edit them. I do this with the following code:
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow(array('index','view'));
}
Now this works fine as they are just redirected to the login page where they can login to access the page but instead of gaining access the get the following error:
Warning (512): Could not find AclComponent. Please include Acl in Controller::$components. [CORE/cake/libs/controller/components/auth.php, line 421]
Notice (8): Undefined property: AuthComponent::$Acl [CORE/cake/libs/controller/components/auth.php, line 527]
Fatal error: Call to a member function check() on a non-object in /Users/cameron/Sites/cake-1.3.8/cake/libs/controller/components/auth.php on line 527
I'm not sure why I'm getting errors about ACL as I'm not using ACL anywhere within my app, all I'm doing is simply saying a user must be logged in to access those OTHER actions.
Any ideas what the problem is and how to fix it?
As you fall on line 527 of the AuthComponent, does it mean that somewhere you configured the AuthComponent with something like this:
$this->Auth->authorize = 'actions';
If this is the case, it has the effect to make the AuthComponent use the AclComponent to check if a user is allowed to perform an action.
See http://book.cakephp.org/view/1250/Authentication#!/view/1275/authorize
Related
I am new in Cakephp i develop my whole website but at some point when anyone type my website name like www.example.com/controllername/action it opens correct but anyone type like www.example.com/xyz then it shows error like
Missing Controller
Error: xyzController could not be found.
Error: Create the class xyzController below in file: app/Controller/xyzController.php
<?php
class xyzController extends AppController {
}
Notice: If you want to customize this error message, create app/View/Errors/missing_controller.ctp
Stack Trace
APP/webroot/index.php line 109 → Dispatcher->dispatch(CakeRequest, CakeResponse)
the same process is apply on action like i type www.example.com/controllername/xyz then it shows error like
Notice: If you want to customize this error message, create app/View/Errors/missing_action.ctp
what i do to remove this message if i create that file in view folder then in header footer it shows undefined variable where i dynamically called variable.what i do.please suggest me,thanks in advanced.
Just create the app/View/Errors/missing_action.ctp file in the given location with your custom message and styles. Then in your appController file just write this:
function beforeRender () {
if ($this->name == 'CakeError') {
$this->layout = false;
}
}
Hope this will work for you. :)
If your site users are seeing error messages like this then it implies that you don't have debug set to 0 which it should be in production.
Make sure you have Configure::write('debug', 0); set in app/Config/core.php. Only enable debugging on a staging or local copy of your site otherwise you risk revealing error messages to users on your live site that may lead to vulnerabilities.
With debug set to 0 the errors will only get logged in your app's error.log and the user will be delivered a 404 page. This is correct as a missing Controller is technically an error.
You are getting errors like this because you're using the magic routing setup when you first install CakePHP to help you build your app. It is a good idea to consider explicitly defining all your app routes in routes.php and disabling the default routing behaviour by removing this line from the file:-
require CAKE . 'Config' . DS . 'routes.php';
If you do this you will not get any error messages for pages that do not exist, but you also will not be able to access any page that a route hasn't been defined for. This is not necessarily a bad thing, Beware the Route to Evil is a good read in regards to this.
We've had an application running on CakePHP 1.3.3 for years without a single hitch, but randomly it's started saying "The requested address /task_scheduler/task_scheduler_mailouts was not found on this server." - but it's only effecting this. Everything else running on that server (including other CakePHP applications) are fine.
When I enable debug in core.php, I get the following error messages:
Notice (8): Undefined variable: currentUser [APP\views\themed\default\layouts\default.ctp, line 50]
Error: The Behavior file app\models\behaviors\null.php can not be found or does not exist.
Error: Create the class below in file: app\models\behaviors\null.php
<?php
class NullBehavior extends ModelBehavior {
}
?>
All of the files are present in /task_scheduler/task_scheduler_mailouts and the currentUser variable is working without any problems on the other pages. currentUser is set in the beforeFilter() function in app_controller.php which as far as I know is used for every single page.
function beforeFilter() {
...
$currentUser = ClassRegistry::init('WfEmployee')->getNetworkUser();
...
}
(update) if I hardcode the $currentUser variable I still get the not set notice. I don't think the beforeFilter() function is even running.
Any ideas as to what could have suddenly caused this error please? Thank you.
function beforeFilter() {
parent::beforeFilter();
$currentUser = ClassRegistry::init('WfEmployee')->getNetworkUser();
...
}
Im getting 2 errors. I saw that Jomsocial had the problem with their own site and fixed it but never posted how. Happens when you go to post an update in jomsocial and it locks up. You refresh the page and get
Error
Sorry, User ID not found.
with the following errors. Then you go login and check the profile and the update was posted fine.
Notice: JFactory::getUser(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CUser" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxxxx/public_html/libraries/joomla/factory.php on line 244
Notice: CUser::CUser(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "CUser" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in /home/xxxxxx/public_html/components/com_community/libraries/user.php on line 52
What version of JomSocial do you use? This issue shouldn't happen
In Magento 1.3.2.2 we get a fatal error:
Fatal error: Call to a member function getUsername() on a non-object in
.../app/design/adminhtml/default/default/template/page/header.phtml on line 31
During an order confirmation, Magento should make a transition to the success page. But we are getting that error instead.
An Admin header is shown with this error. If I refresh, I get to the success page where I should have been taken if everything was ok.
This error happens because header.phtml on line 31 has entry:
$this->getUser()->getUsername();
But getUser() method didn't return valid object. This method pretty simple and looks like this:
return Mage::getSingleton('admin/session')->getUser();
So, you should debug only one place: app/code/core/Mage/Admin/Model/Session.php
Only one method setUser() object to session
public function login($username, $password, $request = null) {
...
$this->setUser($user);
If user object loads and valid it is mean that you have problem with session it self:
check how cookies sets
cookies path and created time
It is not easy find the problem remotely without debugging. So I wish you success.
I had the same error and solved it as follows:
Backup the var folder as (var-back)
Create a new var directory
Backup the locks folder as (locks-back) {if available}
Create the locks directory
Refresh the URL
I have been trying to implement an auth system for Codeigniter. I wanted to save time, though it hasn't succeeded so far.
The system I'm trying to implement is: http://codeigniter.com/wiki/auth/
Currently I have some forms working, but the registration form generates a fatal error:
PHP Fatal error: Call to undefined method CI_Loader::setdata() in /Applications/MAMP/htdocs/CI+Login/system/application/controllers/auth.php on line 159
Anyone has an idea what that is about? Anyone has got this system running?
thx.
EDIT:
The code that generates the error is:
if ($this->config->item('auth_use_security_code'))
$this->authlib->register_init();
$data['countries'] = $this->Usermodel->getCountries();
$this->load->setdata($data);
The problem is that load does not contain a method named setdata, has it in a previous version of CI or what can I make of this?
Try this:
$this->load->vars($data);
or remove this line and use the second parameter of the $this->load->view() function.
$this->load->view($this->config->item('auth_register_view'),$data);