2

I understand I should be able to use the User plugin via [mydomain.com]/users/[controller] e.g. mydomain.com/users/login or possibly mydomain.com/users/users/login, but it comes up Error: The requested address '/users/users/login' was not found on this server.

login seems allowed in UsersController.php as it comes: protected function _setupAuth() {$this->Auth->allow('add', 'reset', 'verify', 'logout', 'view', 'reset_password', 'login');

plugins are loaded, as cake schema shell didn't work until it was.

AppController's beforefilter:

public $components = array(
    'Session',
            'Auth'
    );

 public function isAuthorized($user) {

     return true;
 }

function beforeFilter() {
    $this->Auth->allow('index');
            $this->set('logged_in', $this->Auth->loggedIn());
            $this->set('current_user', $this->Auth->user());
            $this->Auth->authorize = 'controller';
            $this->Auth->fields = array('username' => 'email', 'password' => 'passwd');
            $this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => false);
            $this->Auth->loginRedirect = '/';
            $this->Auth->logoutRedirect = '/';
            $this->Auth->authError = __('Sorry, but you need to login to access this location.', true);
            $this->Auth->loginError = __('Invalid e-mail / password combination.  Please try again', true);
            $this->Auth->autoRedirect = true;
            $this->Auth->userModel = 'User';
            $this->Auth->userScope = array('User.active' => 1);
            if ($this->Auth->user()) {
                $this->set('userData', $this->Auth->user());
            $this->set('isAuthorized', ($this->Auth->user('id') != ''));
    } 
}

}

Other pages I've written (not plugins) seem to work fine.

It comes with a UsersAppController.php...

What am I missing?

Thanks so much!

1 Answers1

1

As documentation, you must load the plugin on this way

CakePlugin::load('Users', array('routes' => true));

that means your routes must be

Router::connect('/users', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/users/index/*', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/users/:action/*', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/users/users/:action/*', array('plugin' => 'users', 'controller' => 'users'));
Router::connect('/login/*', array('plugin' => 'users', 'controller' => 'users', 'action' => 'login'));
Router::connect('/logout/*', array('plugin' => 'users', 'controller' => 'users', 'action' => 'logout'));
Router::connect('/register/*', array('plugin' => 'users', 'controller' => 'users', 'action' => 'add'));

Then for call login just go

/login

Best Regards

Carlos
  • 4,299
  • 5
  • 22
  • 34