User session parameters WEB

Hi

Searching this question I found a couple of Posts talking about. All they speaks about “APP class”. My problem is I cant find where it is. I just need to know where is the best place to reach connectionStateChanged status.

(Searched folder by folder over the entire workspace)

Reading more posts, I figure out App.java must be created by myself. modules/web/src/com/company/myapp/web. Am I right?

Hi @apunzi,

It was a way for older versions of the platform. Now this mechanism is updated and you can you Event Listeners instead. See this example of how to add your logic right after login, where you already know the user.

Regards,
Aleksey

@stukalov
Thanks a lot. I’m dealing whith this sample right now.

At the moment I cant find where to link AfterUserLoginEventListener with the application. It’s a defined file name? it’s just because located at core and executed automatically?..

@apunzi,

This is events approach. This event will be raised on the core tier after successful login. So, you define a component (annotated as @Component) in the core module that implements ApplicationListener<UserLoggedInEvent> interface, a name of the class really doesn’t matter. The onApplicationEvent method is dictated by the interface and will be invoked once the UserLoggedInEvent event is raised.

So, finally it should look like:

@Component
public class MyBusinessLogicAfterUserLogin implements ApplicationListener<UserLoggedInEvent> {
    ...
    @Override
    public void onApplicationEvent(UserLoggedInEvent event) {
        ...
    }
    ...
}

Find more on events and login process the docs:
https://doc.cuba-platform.com/manual-6.8/events.html
https://doc.cuba-platform.com/manual-6.8/login.html

Regards,
Aleksey

1 Like

Now I got it. Thank you very much, again. Appologizes for my ignorance.

Moreover, take a look at the events of the Web tier: com.haulmont.cuba.web.security.events

See docs: https://doc.cuba-platform.com/manual-6.8/web_login.html#web_login_events