[keycloak-user] keycloak-session returns userModel as null in eventListenerProvider SPI

abhishek raghav abhi.raghav007 at gmail.com
Wed Nov 16 16:10:52 EST 2016


Hi

I am trying to implement a welcome email to newly registered users by admin.
I am using event listener SPI and emailSenderProvider to do this.

I am implementing a provider for the Event Listener SPI and notifying users
by sending an email and react to create user OperationType using
emailSenderProvider.

Here i am overriding, onEvent method which gets triggered on any
AdminEvents.
Now inside this method, i am preparing the content and calling
emailSenderProvider.send() which takes realmModel and userModel.

The issue is, I am able to get the realmModel, but not the userModel.
Code for reference:
@Override
public void onEvent(AdminEvent event, boolean includeRepresentation) {
UserModel user =
session.users().getUserById(event.getAuthDetails().getUserId(), realm);
......

Same works perfectly in the onEvent() for loginEvents.

Is it that the newly created resource is not available in the session but
when we try updating an existing resource, it is able to fetch it.

Please help me where I am doing wrong. Or is there any other way to get the
userModel object.

Thanks in advance.

Cheers
Abhishek


More information about the keycloak-user mailing list