user register page not authorized
trying to access the register page throws "You are not authorized to access that location." error and redirects to login. This happens on a fresh install as soon as I extend the users entity/table/controller and set them to be used in the users config. Following the extending the plugin documentation, even with no model overrides on the MyUsers entity and the my_users table in my database is an exact copy of the users table
Controller/MyUsersController.php
namespace App\Controller;
use App\Controller\AppController;
use App\Model\Table\MyUsersTable;
use Cake\Event\Event;
use CakeDC\Users\Controller\Component\UsersAuthComponent;
use CakeDC\Users\Controller\Traits\LoginTrait;
use CakeDC\Users\Controller\Traits\RegisterTrait;
class MyUsersController extends AppController
{
use LoginTrait;
use RegisterTrait;
//add your new actions, override, etc here
}
Model/Entity/MyUser.php
namespace App\Model\Entity;
use CakeDC\Users\Model\Entity\User;
/**
* Application specific User Entity with non plugin conform field(s)
*/
class MyUser extends User
{
/**
* Map CakeDC's User.active field to User.is_active when getting
*
* @return mixed The value of the mapped property.
*/
/*protected function _getActive()
{
return $this->_properties['is_active'];
}*/
/**
* Map CakeDC's User.active field to User.is_active when setting
*
* @param mixed $value The value to set.
* @return static
*/
/*protected function _setActive($value)
{
$this->set('is_active', $value);
return $value;
}*/
}
Model/Table/MyUsersTable.php namespace App\Model\Table;
use CakeDC\Users\Model\Table\UsersTable;
/**
* Application specific Users Table with non plugin conform field(s)
*/
class MyUsersTable extends UsersTable
{
}
users.php config chunk (copied the config file from the plugin and only changed these 2 items)
$config = [
'Users' => [
// Table used to manage users
'table' => 'MyUsers',
// Controller used to manage users plugin features & actions
'controller' => 'MyUsers',
Please paste your bootstrap.php code to load the plugin and permissions.php file. Thanks,
Hi skywalkerx86,
did you solve this issue? How? I have the same problem and would appreciate if you could point out what worked for you.
Thanks,
Kai
Hi skywalkerx86,
did you solve this issue? How? I have the same problem and would appreciate if you could point out what worked for you.
Thanks,
Kai
Sorry, I don't think I ever sorted this out.
I had a similar issue when starting with this, the only solution I found was to extend the CakeDC classes directly. So instead of MyUserController extends AppController, I used MyUserController extends CakeDCUserController (with an appropriate use statement for the alias).