diff --git a/src/Application.php b/src/Application.php index 0bf89c9..aad0322 100644 --- a/src/Application.php +++ b/src/Application.php @@ -120,8 +120,9 @@ class Application extends BaseApplication implements AuthenticationServiceProvid ])); \SocialConnect\JWX\JWT::$screw = Configure::check('keycloak.screw') ? Configure::read('keycloak.screw') : 0; } - $middlewareQueue->add(new AuthenticationMiddleware($this)) - ->add(new BodyParserMiddleware()); + $middlewareQueue + ->add(new BodyParserMiddleware()) + ->add(new AuthenticationMiddleware($this)); return $middlewareQueue; } diff --git a/templates/Users/login.php b/templates/Users/login.php index 60d6054..f9de87f 100644 --- a/templates/Users/login.php +++ b/templates/Users/login.php @@ -20,7 +20,7 @@ use Cake\Core\Configure; $this->Form->setTemplates($template); if (!Configure::check('password_auth.enabled') || Configure::read('password_auth.enabled')) { echo sprintf('

%s

', __('Sign In')); - echo $this->Form->create(null, ['url' => ['controller' => 'users', 'action' => 'login']]); + echo $this->Form->create(null, ['url' => ['controller' => 'users', 'action' => 'login', '?' => ['redirect' => $this->request->getQuery('redirect')],]]); echo $this->Form->control('username', ['label' => 'Username', 'class' => 'form-control mb-2', 'placeholder' => __('Username')]); echo $this->Form->control('password', ['type' => 'password', 'label' => 'Password', 'class' => 'form-control mb-3', 'placeholder' => __('Password')]); echo $this->Form->control(__('Login'), ['type' => 'submit', 'class' => 'btn btn-primary']);