Open automatically a login form in a modal

Hi, I have a Login form in a modal (modLogin) in the main layout of my home page.
I created a route “/login” pointing to the home page as well (so I can redirect a user to the login form) and I want that when a user visits this route, the modal will open automatically if the user is not logged in and otherwise be redirected to the home page (/) with the modal hidden.
I’ve tried to use the “ready” event in the App (body) element to get it, but I can´t make it work.
The code is the following:

It seems that the identity in the service connect “scUser” is not available at this stage so the modal is displayed even if the user is logged in. What is wrong? Does anyone have a different solution to achieve the goal to redirect a user to the login form in a modal? Thanks

Community Page
Last updated: