Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user register page not authorized #689

Open
skywalkerx86 opened this issue May 1, 2018 · 6 comments
Open

user register page not authorized #689

skywalkerx86 opened this issue May 1, 2018 · 6 comments

Comments

@skywalkerx86
Copy link

skywalkerx86 commented May 1, 2018

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',
@steinkel
Copy link
Member

Please paste your bootstrap.php code to load the plugin and permissions.php file. Thanks,

@kaihoefler
Copy link

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

@skywalkerx86
Copy link
Author

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.

@niel
Copy link

niel commented Jun 20, 2019

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).

@ajibarra
Copy link
Member

@skywalkerx86 @niel is this still an issue in current versions?

@niel
Copy link

niel commented Jun 28, 2024

@skywalkerx86 @niel is this still an issue in current versions?

I have no idea, as I'm not using the current versions in anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants