How to turn off logging back to same screen?

One of my client has specific use case where the same computer is used by multiple users who do not have the same access rights. After on user logs off or closes the application abnormally, when another user logs in, the system tries to load the last loaded screen. But when the 2nd user doesn’t have access right to that page, the systems gives error.

image

Error

image

In such use cases, how can we handle this problem?

Hi,

What Jmix version are you using? I tried 2.5.1, and the LogoutButton didn’t redirect me back to the last view.

Redirecting is implemented in io.jmix.securityflowui.authentication.LoginViewSupport#showInitialView. You can override this and provide any logic you need, for example, redirecting to the main view if the cached route is denied.

Regards,
Gleb

Hi Gleb
My client is using in SSO environment. I’m using Version 2.5.1

Where can I override, in application.properties? Thanks for providing the code snippets.

LoginViewSupport is a Spring bean. Simply extend it and make it primary. Since the LoginView is scaffolded in the project, you can inject your custom LoginViewSupport bean directly, whatever suits you best.

1 Like

Hi Gleb
Thanks.
Will this be like as follows?

import io.jmix.flowui.ViewNavigators;
import io.jmix.securityflowui.authentication.LoginViewSupport;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
@Primary
public class CustomLoginViewSupport extends LoginViewSupport {

    private final ViewNavigators viewNavigators;

    public CustomLoginViewSupport(ViewNavigators viewNavigators) {
        this.viewNavigators = viewNavigators;
    }

    @Override
    protected void showInitialView() {

        viewNavigators.view(this, "MainView").navigate();
    }
}

and in application properties:

io.jmix.securityflowui.authentication.LoginViewSupport#showInitialView

Hi,

If it does what you expected then it’s correct :wink: Also, you don’t need to add anything to the application.properties.