How to Check if user is logged in cakephp 4 application using CakeDC users plugin ? I need to change the theme when the user is logged in
In Application.php
public function bootstrap(): void
{
$this->addPlugin('BootstrapUI');
// Call parent to load bootstrap from files.
parent::bootstrap();
$this->addPlugin('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);
//$this->addPlugin(\CakeDC\Users\Plugin::class);
Configure::write('Users.config', ['users']);
}
In AppController.php
public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);
$user = $this->Authentication->identify();
if ($user) {
$this->viewBuilder()->setlayout( 'CakeLte.default' );
}
}