feat: company code and status, company on events and emails, admin login names
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
4243a2d6cd
commit
840b5a3bae
6 files changed
+124
-1
No files matched your search
@@ -0,0 +1,24 @@
|
||||
-- Co-Lite change add-company-scoping: admin sign-in names.
|
||||
-- Super admins (role 1) belong to no company and keep their username.
|
||||
-- Every other admin user keeps company 1 (INS) and is renamed username@ins; they sign in with company "ins".
|
||||
-- Ends every admin session (token subjects no longer match). Run once, after 01 and 02.
|
||||
USE `service-system`;
|
||||
|
||||
-- Stop if any admin username already contains '@': it would be ambiguous after the rename.
|
||||
DROP PROCEDURE IF EXISTS `colite_check_admin_usernames`;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE `colite_check_admin_usernames`()
|
||||
BEGIN
|
||||
IF EXISTS (SELECT 1 FROM `user` WHERE `type` = 'A' AND `username` LIKE '%@%') THEN
|
||||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'An admin username contains @; rename it before running this script';
|
||||
END IF;
|
||||
END //
|
||||
DELIMITER ;
|
||||
CALL `colite_check_admin_usernames`();
|
||||
DROP PROCEDURE `colite_check_admin_usernames`;
|
||||
|
||||
UPDATE `user` u SET u.`company_id` = NULL
|
||||
WHERE u.`type` = 'A' AND EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1);
|
||||
|
||||
UPDATE `user` u SET u.`company_id` = 1, u.`username` = CONCAT(u.`username`, '@ins')
|
||||
WHERE u.`type` = 'A' AND NOT EXISTS (SELECT 1 FROM `users_roles` r WHERE r.`user_id` = u.`id` AND r.`role_id` = 1);
|
||||
Reference in new issue
Block a user