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 6, 2024
1 parent 6ac2205 commit a235562
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 a235562

Please sign in to comment.