yii2yii2-user

yii2 login page for advanced templet with admin lte and yii2-user extension


Has anybody tried using the AdminLTE Theme with yii2-user extension? The login to the admin page didn't work for me. I am using localhost for frontend and localhost/admin for backend. The frontend is working fine but I couldn't get it work for backend due to the AdminLTE theme. Any clues?

I suspect the issue is in the below code snippet. It is using the default SitController rather than the AdminController from the yii2-user extension.

The below code is from backend/view/layout/main.php

if (Yii::$app->controller->action->id === 'login') {
echo $this->render(
    'main-login',
    ['content' => $content]
);
} 

Solution

  • Adding the below config in the backend main.conf fixed my issue.

    'user' => [
        // following line will restrict access to admin page
        'class' => 'dektrium\user\Module',        
        'as backend' => 'dektrium\user\filters\BackendFilter',
        **'controllers' => ['profile', 'recovery', 'registration', 'settings'],**
    ],