0
votes

I am start going through the cakephp tutorials, I copy the source code exactly as shown in the tutorial.

I have done the Blog tutorial and all seems good, now I am onto the "Simple Authentication and Authorization Application" (http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html) tutorial, but are running into this issue.

  1. The add page loads fine:

    ".../app/webroot/index.php/Users/add"

  2. After hitting submit, it redirects me to this url (with the additional "Users" string) and with an error message.

    ".../app/webroot/index.php/Users/Users/add"

    Missing Method in UsersController
    
    Error: The action Users is not defined in controller UsersController
    
    Error: Create UsersController::Users() in file: app/Controller/UsersController.php.
    
    class UsersController extends AppController {
    
    
    public function Users() {
    
    }
    
    }
    

Let me know where I should start checking, Thanks.


AppController

    class AppController extends Controller {
        public $components = array(
            'Session',
            'Auth' => array(
                'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
                'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
                'authorize' => array('Controller') // Added this line
            )
        );

        public function beforeFilter() {
            $this->Auth->allow('index', 'view');
       }

        public function isAuthorized($user) {
        // Admin can access every action
        if (isset($user['role']) && $user['role'] === 'admin') {
            return true;
        }

        // Default deny
        return false;
      }
    }
1
/app/webroot/index.php/Users/add? it could be a url rewriting issue: have you followed the url rewriting tutorial: book.cakephp.org/2.0/en/installation/url-rewriting.html - ptica

1 Answers

1
votes

Because I still can't comment, I'll tell you here and edit this answer if I know it.

Show me your AuthComponent configuration in AppController.php.

EDIT:

Answer is in the comments below. :)