fix: retain active identity when upgrading duplicate SSO records

This commit is contained in:
SantaSpeen committed 2026-10-21 21:49:39 +03:00
1 parent bd9bf33bc9
commit a0de540dbd
3 files changed
+56 -1

No files matched your search

+11
View File
@@ -121,6 +121,17 @@ func NewSSO(ctx context.Context, store *storage.Storage, server *settings.Server
}
}
}
// A previous build may have created duplicate rows after corrupting the
// username index. Keep the currently indexed record when it is valid, so
// updating its profile cannot collide with that same identity's other row.
for username := range s.userIDs {
indexed, lookupErr := store.Users.Get(server.Root, server.FollowExternalSymlinks, username)
if lookupErr == nil && indexed.Username == username {
s.userIDs[username] = indexed.ID
} else if lookupErr != nil && !errors.Is(lookupErr, fberrors.ErrNotExist) {
return nil, lookupErr
}
}
return s, nil
}