Skip to content

Commit

Permalink
Avoids identities duplication when recreated in kc
Browse files Browse the repository at this point in the history
When user is recreated in KC, the backend sees a new externalId,
which causes a new identity to be created, with a non updated attributes
  • Loading branch information
minottic committed Jun 5, 2024
1 parent 129199a commit 9132a49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion helm/configs/backend/login-callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

exports.accessGroupsToProfile =
function (req, done) {
return function (err, user, identity, token) {
return async function (err, user, identity, token) {
await user.identities.destroyAll({and: [
{provider: identity.provider},
{id: {neq: identity.id}},
{userId: user.id}
]});
identity.updateAttributes({
"profile": {
accessGroups: identity.profile._json.pgroups,
Expand Down

0 comments on commit 9132a49

Please sign in to comment.