[keycloak-user] attributes are not persisted
Max Bruchmann
max.bruchmann at hotmail.com
Fri Aug 10 13:32:29 EDT 2018
Hmm unfortunatelly if I use
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (session) -> {
UserModel user = getUserModel(session, userId, realmId);
...
The user is null :/
Max
Am 10.08.18 um 09:03 schrieb Marek Posolda:
I am not 100% sure, but it's possible that updating users in the events don't currently work. Reason is, that transaction might be already commited. The possible solution long term is to use pre/post events for this (which we don't yet support).
For the short term, it may be possible to manually trigger your own temporarily transaction (You can take a look at KeycloakModelUtils.runJobInTransaction method). Note that in the new transaction, you need to ensure to not use Hibernate entities from the "outer" transaction (EG. all the things like RealmModel, UserModel need to be look-up again through the Model API in the new transaction).
Marek
On 09/08/18 21:39, Max Bruchmann wrote:
Hi,
I have a custom EventListenerProvider that consumes Register and Login events.
On register it creates some external resource
...//on register
String externalID = createSomethingWithUserEmail(userModel.getEmail())
userModel.setSingleAttribute("foo", externalID)
...
On login I need to todo some additional calls with the already created id.
...// on login
String externalID = userModel.getFirstAttribute("foo");
doSomeUpdate(externalID, userModel.getFirstName(), userModel.getLastName())
...
Unfortunatelly the retrieved id via getFirstAttribute seems to be null.
Is there anything I need todo when modifying attributes so they are persisted?
Kind Regards,
Max
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org<mailto:keycloak-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-user
More information about the keycloak-user
mailing list