maiconpinto / cakephp-adminlte-theme

CakePHP AdminLTE Theme
http://maiconpinto.github.io/cakephp-adminlte-theme/
MIT License
172 stars 111 forks source link

´CSRF issue in the login - plugin not usable! #109

Closed VARGA-Peter closed 4 years ago

VARGA-Peter commented 4 years ago

I refer to this thread: https://github.com/cakephp/cakephp/issues/14550

It looks like the form isn't created properly. Can you please check it and let me know? For the moment I can disable the check in ` CsrfProtectionMiddleware.php but it should be solved ASAP.

I am using it with CakePHP 4.1.0

VARGA-Peter commented 4 years ago

I could solve it on my own. I need 1 day as I started 2 days ago with CakePHP and I had to understand the logic.

You can use my below fix, it's also CSRF safe and I respected your layout and functionality so it shouldn't be a problem for implementing it in one of your next versions.

/templates/Pages/examples/login.php

<?php $this->layout = 'login'; ?>

    <?= $this->Form->create() ?>
    <fieldset>
        <div class="form-group has-feedback">
            <?= $this->Form->control('email',    ['required' => true, 'placeholder' => 'Email',    'label' => FALSE, 'class' => 'form-control']) ?>
            <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
        </div>
        <div class="form-group has-feedback">
            <?= $this->Form->control('password', ['required' => true, 'placeholder' => 'Password', 'label' => FALSE, 'class' => 'form-control']) ?>
            <span class="glyphicon glyphicon-lock form-control-feedback"</span>
        </div>
        <div class="row">
            <div class="col-xs-8">
                <div class="checkbox icheck">
                    <label>
                        <input type="checkbox">&nbsp;&nbsp;Remember Me
                    </label>
                </div>
            </div>
        </div>
    </fieldset>
    <?= $this->Form->submit(__('Login')); ?>
    <?= $this->Form->end() ?>