Hi,
I created a class implementing the EventListenerProvider interface, and on
the 'register' event, when I retrieve the newly created user, both the
first and last name are set to null. The newly created user has their
first and last name set later on, but I was wondering if it was possible to
get that information during the 'register' event.
public class MyListenerProvider implements EventListenerProvider {
private KeycloakSession session;
public MyListenerProvider(KeycloakSession session) {
this.session = session;
}
public void onEvent(Event event) {
EventType eventType = event.getType();
if(eventType.equals(EventType.REGISTER)) {
String realmId = event.getRealmId();
String userId = event.getUserId();
RealmModel realm = session.getContext().getRealm();
UserModel user = session.users().getUserById(userId, realm);
String username = user.getUsername();
// the following are null for newly created users
String firstName = user.getFirstName();
String lastName = user.getLastName();
}
}
public void onEvent(AdminEvent event, boolean includeRepresentation) {
}
public void close() {
}
}
Thanks!
--
Danny Im
Software Developer
Polar Geospatial Center
University of Minnesota
Show replies by date