Render login page in modal instead of page

I have managed to show login page in bootstrap modal.

but in a case accessing user/profile without login redirects to user/login page.

now, i want to show or open login page in modal instead of redirecting to ‘user/login’ page.

config/main.php


'user' => array(

            'class' => 'application.components.WebUser',

            'allowAutoLogin' => true,

            'loginUrl' => array('user/login'),

        ),

How this can be done?

is there any way to do this?

The problem is that you should intercept every action of every controller, because if you don’t make redirect, every controller action has to be executed.

I think that the simplest way is to use anyway a redirect and after loaded open immediately the login poup.

is there a way to stay on same page and just open login modal.

after redirect it will have login form on page also on modal (after opening modal).