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

More details in the README.md #11

Open
CeriseGoutPelican opened this issue Mar 4, 2019 · 4 comments
Open

More details in the README.md #11

CeriseGoutPelican opened this issue Mar 4, 2019 · 4 comments
Labels

Comments

@CeriseGoutPelican
Copy link

Hey hi!

Thank you very much for the work you've done here! I juste have one or two questions on how to use your plugin. I installed it via composer and loaded it from the Auth Component.

$this->loadComponent('Auth', [
    'authenticate' => [
        'Form' => [
            'finder' => 'auth'
        ],
        'RememberMe.Cookie' => [
            'cookie' => [
                'name'     => 'rememberMe',
                'expires'  => '+30 days',
                'secure'   => true,
                'httpOnly' => true,
            ],
        ],
    ],
    'loginAction' => [
        'controller' => 'Users',
        'action'     => 'login',
        'prefix'     => false
    ],
    'loginRedirect' => [
        'controller' => 'Pages',
        'action'     => 'home',
        'prefix'     => false
    ],
    'logoutRedirect' => [
        'controller' => 'Pages',
        'action'     => 'home',
        'prefix'     => false
    ],
    'authError' => __("Vous n'êtes pas autorisé à accéder à cette section."),
    'authorize' => ['Controller'], 
]);

Plus in my login form I added the following lines :

<?= $this->Form->create() ?>
    <?= $this->Form->control('username', ['label' => '', 'placeholder' => __('Pseudonyme')]); ?>
    <?= $this->Form->control('password', ['label' => '', 'placeholder' => __('Mot de passe')]); ?>
	<?= $this->Form->control('remember_me', ['type' => 'checkbox', 'label' => __("Se souvenir de moi ?")]); ?>	
	<?= $this->Form->button(__('Connexion')); ?>
<?= $this->Form->end() ?>

Is there anything else that is needed to make the plugin works? After a login, nothing happends and there is no cookie generated.

Maybe I missed something? It would be great if you could add some informations regarding the installation.

I'm using php 7.2.7 and Cakephp 3.7

document.cookie
<- ""
@nojimage
Copy link
Owner

nojimage commented Mar 5, 2019

Are you executed migration script and created remember_me_tokens table?

if you don't have remember_me_tokens table, running migration script that below:

bin/cake migrations migrate -p RememberMe

Also, if there is an error log in the logs/ directory, it may be helpful to look at it.

Thanks.

@CeriseGoutPelican
Copy link
Author

Thank you very much for your answer and the cookie is now working well. However, there is one weird thing left. I'll try to describe it my best:

  1. I login with the "remember me" option
  2. After a while the session ends, and I’m disconnected in appearance (the menu from the layout doesn’t display my information anymore and all the $this->Auth->user() is null) BUT I can still have access to the prefixed part of the website (if a user is disconnected I normally have an error)
  3. If I change the page, I’m automatically connected again and everything seems fine

There is no error about this problem in the logs/error.log file

Thanks for your help!

@nojimage
Copy link
Owner

Thank you for the report.
It seems that user information is not set to the session when authenticating with CookieAuthenticate.
I'll try to fix the user information in the session by default when logging in with CookieAuthenticate.

@nojimage
Copy link
Owner

Hmmm. Currently, it seems that the session of user information is also set at the time of user authentication with AuthComponent.

https://github.com/cakephp/cakephp/blob/3.7.4/src/Controller/Component/AuthComponent.php#L755

The cause may be the timing of get user information in display logic, but I am not sure.
It may be helpful to try using DebugKit for check the session state when the menu display fails.

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

No branches or pull requests

2 participants