Skip to content

Commit 708285f

Browse files
caseysoftwareclaude
andcommitted
Give existing users without a contact a placeholder contact
Users created before the previous fixes (most often by an LDAP login whose contact insert failed) have user_contact = 0. They are missing from User Management and the per-user permission check denies viewing them, so an admin has no way to give them a role. Migration 065 creates a minimal contact named after the login name for every user whose contact is missing, links it to the user, and is a no-op when there are none. Refs #320 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016CP89WVmGZ1VVCCZMS6ntN
1 parent 27b2354 commit 708285f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- Users without a contact record (for example LDAP users whose contact could
2+
-- not be saved on their first login) are missing from User Management and
3+
-- cannot be viewed or given a role. Give each of them a minimal contact named
4+
-- after the login name. The marker in contact_notes links the new contact to
5+
-- its user and is removed afterwards.
6+
-- https://github.com/web2project/web2project/issues/320
7+
8+
INSERT INTO `contacts` (`contact_first_name`, `contact_last_name`, `contact_display_name`, `contact_order_by`, `contact_owner`, `contact_notes`)
9+
SELECT u.`user_username`, '', u.`user_username`, u.`user_username`, 0, CONCAT('w2p-065-user:', u.`user_id`)
10+
FROM `users` u
11+
LEFT JOIN `contacts` c ON c.`contact_id` = u.`user_contact`
12+
WHERE c.`contact_id` IS NULL;
13+
14+
UPDATE `users` u
15+
JOIN `contacts` c ON c.`contact_notes` = CONCAT('w2p-065-user:', u.`user_id`)
16+
SET u.`user_contact` = c.`contact_id`;
17+
18+
UPDATE `contacts` SET `contact_notes` = NULL WHERE `contact_notes` LIKE 'w2p-065-user:%';

0 commit comments

Comments
 (0)