Thanks Stian:
Your suggestion works well for 'create' and 'update' events, but when I
try to use the session.users().getUserById(userId, realm), the result is null.
☹
if (event.getRealmId() != null && event.getAuthDetails().getUserId() != null
&& event.getResourcePath() != null &&
event.getResourcePath().startsWith("users/")) {
RealmModel realm = model.getRealm(event.getRealmId());
String userId =
event.getResourcePath().substring(event.getResourcePath().lastIndexOf("/")+1);
UserModel user = session.users().getUserById(userId, realm);
if (user != null) {
if(OperationType.DELETE.equals(event.getOperationType())){
//Deleting the user in Hubspot
log.infov("Deleting the user (ID={0}) in
Hubspot...", user.getEmail());
}else
if(OperationType.UPDATE.equals(event.getOperationType())){
//Deleting the user in Hubspot
log.infov("Updating the user (ID={0}) in
Hubspot...", user.getEmail());
}else
if(OperationType.CREATE.equals(event.getOperationType())){
//Deleting the user in Hubspot
log.infov("Registering the user (ID={0}) in
Hubspot...", user.getEmail());
}
}else{
log.errorv("No User found with ID={0}, Operation={1}", userId,
event.getOperationType());
}
}else{
log.errorv("No Realm ID or User ID found");
}
2016-06-13 11:22:02,502 INFO
[com.itroi.keycloak.events.hubspot.HubspotEventListenerProvider] (default task-56)
Registering the user (ID=user500(a)mail.com) in Hubspot...
2016-06-13 11:22:19,463 INFO
[com.itroi.keycloak.events.hubspot.HubspotEventListenerProvider] (default task-64)
Updating the user (ID=user500(a)mail2.com) in Hubspot...
2016-06-13 11:22:32,403 ERROR
[com.itroi.keycloak.events.hubspot.HubspotEventListenerProvider] (default task-7) No User
found with ID=179e55e6-5788-4a10-a640-6661485bfa95, Operation=DELETE
Jairo Henao Rojas
IT ROI Solutions
Software Architect
Mobile : 314-738-6032
Office Colombia: + (571) 381-9185
Office Mexico: + 52-81-4624-4468
Office Chile: + 5622-582-2257
Office USA: 954-518-3330
Office Canada: 604-998-2280
jahenao@itroisolutions.com<mailto:jahenao@itroisolutions.com>
[cid:image001.png@01CFACA6.CA39D4D0]
[Description: Description:
cid:image002.png@01CD70CF.8782CD50]<https://twitter.com/ITROISolutions>[Description:
Description:
cid:image003.png@01CD70CF.8782CD50]<http://www.linkedin.com/company/itroi-solutions>
[Description: Description: cid:image004.png@01CD70CF.8782CD50]
<
http://www.facebook.com/pages/IT-ROI-Solutions-CA-Clarity-Consultants/110...
[Description: Description: cid:image005.png@01CD70CF.8782CD50]
<
http://www.youtube.com/user/ITROISolutions>
From: Stian Thorgersen [mailto:sthorger@redhat.com]
Sent: Monday, June 13, 2016 8:28 AM
To: Jairo Henao <jahenao(a)itroisolutions.com>
Cc: keycloak-user(a)lists.jboss.org
Subject: Re: [keycloak-user] Getting the user email before delete it
You can get the user object from session.users().getUserById(..), which will give you the
email.
On 11 June 2016 at 08:58, Jairo Henao
<jahenao@itroisolutions.com<mailto:jahenao@itroisolutions.com>> wrote:
Hello community:
I have a listener that is pending when an administrator deletes a user. How I can get the
user email?
Apparently I can only get his ID, but I need his email to delete it in HubSpot.
There is something like a pre-delete event?
Thanks,
Jairo Henao Rojas
IT ROI Solutions
Software Architect
Mobile : 314-738-6032<tel:314-738-6032>
Office Colombia: + (571) 381-9185<tel:%28571%29%20381-9185>
Office Mexico: + 52-81-4624-4468<tel:%2B%2052-81-4624-4468>
Office Chile: + 5622-582-2257
Office USA: 954-518-3330<tel:954-518-3330>
Office Canada: 604-998-2280<tel:604-998-2280>
jahenao@itroisolutions.com<mailto:jahenao@itroisolutions.com>
[cid:image001.png@01CFACA6.CA39D4D0]
[Description: Description:
cid:image002.png@01CD70CF.8782CD50]<https://twitter.com/ITROISolutions>[Description:
Description:
cid:image003.png@01CD70CF.8782CD50]<http://www.linkedin.com/company/itroi-solutions>
[Description: Description: cid:image004.png@01CD70CF.8782CD50]
<
http://www.facebook.com/pages/IT-ROI-Solutions-CA-Clarity-Consultants/110...
[Description: Description: cid:image005.png@01CD70CF.8782CD50]
<
http://www.youtube.com/user/ITROISolutions>
_______________________________________________
keycloak-user mailing list
keycloak-user@lists.jboss.org<mailto:keycloak-user@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-user