0

In CakePHP I have this configuration:

//Config/routes.php
Router::connect('/viewServices', array('plugin' => 'usermgmt', 'controller' => 'services', 'action' => 'viewServices'));

//View/Users/dashboard.ctp
<?php echo $this->Html->link(__("Services",true),"/viewServices")?>

//View/Services/view_services.ctp
//I put here the view..

//Controller/ServicesController.php
public function viewServices(){
....
}

Now I can't understand the reason why it doesn't works!

I can't see the "view_services.ctp". The server redirects me to the "access_denied.ctp" page, but in the "view_services.ctp" I didn't put any control about the authentication, so maybe I'm doing other errors. Can somebody helps me?

Thanks!

tereško
  • 58,060
  • 25
  • 98
  • 150
SirPilgrims
  • 17
  • 1
  • 5
  • Try `$this->Auth->allow('viewServices');` – Carl0s1z Jul 02 '14 at 10:33
  • are you using Auth in your app controller? – Anik Jul 02 '14 at 10:34
  • "view_services" is for users. I've also a "manage_services" for admin. In this second case, I put: UserAuth->getGroupName()=='Admin') { ?> then there is the view code and it works! So, I'd like to do something like it, but for Users. I thought to delete the prevoius line because everybody can see this page, so I don't need the UserAuth. No? – SirPilgrims Jul 02 '14 at 10:45
  • Rename viewServices function to view_services – Fury Jul 02 '14 at 10:58
  • I tried, but it doesn't works. I have a really similar function that works using manageServices instead of viewServices, manage_services.ctp instead of view_services.ctp with the correct line in the routes.php.. It works! I'm going crazy! – SirPilgrims Jul 02 '14 at 11:05
  • I put all the code here: https://gist.github.com/SirPilgrims – SirPilgrims Jul 02 '14 at 13:06
  • Are you useing ACL or Auth? – Fury Jul 02 '14 at 13:27
  • did you try @CTravel solution? – Fury Jul 02 '14 at 15:10
  • I tried, but the problem is that I'm using the Usermgmt plugin and I'd like to extend it. This plugin use a custom AuthComponent called UserAuthComponent and the function "allow" doesn't exist. Teorically it should works (like other pages) without "allow" – SirPilgrims Jul 02 '14 at 15:39
  • @IsaacRajaei not on his code example, but i always use it, for pages where users dont need to be logged in and it works... – Carl0s1z Jul 02 '14 at 15:52
  • So are you using AuthComponent with Usermgmt plugin? I don't remember the error but I didn't see well.. Tomorrow morning I'll try again and then I'll say you.. Thanks very much to everybody! – SirPilgrims Jul 02 '14 at 20:05
  • So, I tried to add the command that you suggest to view_services.cpt but it doesn't works (correctly, I think). I tried also in the dashboard.cpt, but I receive this error: Missing Helper Error: Usermgmt.AuthHelper could not be found. Error: Create the class AuthHelper below in file: /opt/lampp/htdocs/cakephp/app/Plugin/Usermgmt/View/Helper/AuthHelper.php – SirPilgrims Jul 03 '14 at 07:24
  • Hi everybody! I can't understand how to integrate AuthComponent in Usermgmt plugin. Can anybody helps me? – SirPilgrims Jul 04 '14 at 07:56

1 Answers1

0

I solved the problem changing it:

//Controller/Component/UserAuthComponent.php
.....
//CHANGE IT:
//if(!$userGroupModel->isUserGroupAccess($controller, $action, $this->getGroupId()))
//WITH IT:
if(!$userGroupModel->isUserGroupAccess($controller, $action, 1))

In this way, it works!

Thanks to everybody!

SirPilgrims
  • 17
  • 1
  • 5