mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
After importing a Trello board and choosing to map users later, "Map to existing user" listed only the admin: the picker offered nothing but the ACTIVE REAL MEMBERS of the board, and right after an import the real people have no membership at all - the placeholders do. There was no search box either, so on a board whose only real member is the importing admin there was literally nobody to pick. The picker now has a search box that goes through the same permission-checked `searchUsers` method the normal add-member typeahead uses, so the same board membership check and the same #6116 same-org/team restriction apply. With the box empty it still lists the board's real members (the common case, which changes no roles at all); typing searches every real user and labels the ones who are not on this board yet. Mapping onto a user who is not a board member adds them to the board with the PLACEHOLDER's OWN role - the role the import recorded for that person - never a higher one, and only after passing exactly the checks inviting them would: the Admin Panel "roles allowed to invite" setting, the same-org/team restriction, and the refusal to add a deactivated account. Adding a member with a chosen role is something the board admin doing the mapping can already do through the normal add-member flow, so this grants no capability the caller did not have; an existing active member is still left completely untouched, entry and role. Also fixes sanitizeUserForSearch dropping `profile` from every search result: it read the Mongo-style paths in its allowlist ('profile.fullname') as FLAT keys, so the lookup was always undefined and both this picker and the add-member typeahead showed a blank name with only the username in brackets. Dotted paths are now copied into the same nested shape, still allowlisting exactly the listed leaves. Adds positive and negative unit tests for the new planner contract, including that a comment-only placeholder can never yield an admin, that reactivating an inactive membership does not duplicate the entry, and that the invite policy runs before any write. Thanks to AmigaAbattoir and xet7 ! Fixes #6519,