feat: Enhance user group management and transaction handling in stored procedures

- Improved user group deletion logic to accurately report success or failure.
- Updated user group renaming checks to prevent unintended inserts or updates.
- Added documentation on transaction blocking risks during full resets in stored procedures.
- Removed unnecessary login scripts from database project.
This commit is contained in:
Stefan
2026-09-16 09:42:32 +02:00
parent 8bcec409c5
commit b26c24ef98
9 changed files with 115 additions and 24 deletions
@@ -13,6 +13,11 @@ BEGIN
SET NOCOUNT ON;
DECLARE @utcnow datetime = GETUTCDATE();
DECLARE @auth smallint = [dbo].[fis_admin_getUserAuth](@authaccount);
-- Tracks whether THIS call actually soft-deleted an active group, so a never-existing or
-- already-deleted @usergroup_id reports failure instead of a false "ok:true" (the previous
-- version derived success from "not currently active", which is also true when nothing here
-- ever existed).
DECLARE @deleted bit = 0;
IF @auth > 1 AND EXISTS (SELECT * FROM [dbo].[fis_usergroups] WHERE [usergroup_id] = @usergroup_id and [DateDeleted] is null)
BEGIN
@@ -21,10 +26,22 @@ BEGIN
SET [UserDeleted] = @authaccount
,[DateDeleted] = @utcnow
WHERE
[usergroup_id] = @usergroup_id;
[usergroup_id] = @usergroup_id
AND [DateDeleted] is null;
IF @@ROWCOUNT > 0 SET @deleted = 1;
-- Soft-delete the group's active memberships too, matching the confirm text
-- ("Die Mitgliedschaft aller Benutzer in dieser Gruppe geht dabei verloren.").
UPDATE [dbo].[fis_usergroups_members]
SET [UserDeleted] = @authaccount
,[DateDeleted] = @utcnow
WHERE
[usergroup_id] = @usergroup_id
AND [DateDeleted] is null;
END
SELECT CAST((CASE WHEN NOT EXISTS (SELECT * FROM [dbo].[fis_usergroups] WHERE [usergroup_id] = @usergroup_id and [DateDeleted] is null) THEN 1 ELSE 0 END) as bit);
SELECT @deleted;
END