Files
Fuchs_Intranet/Fuchs_Database/dbo/Stored Procedures/fis_admin_delUserAccount.sql
T
StefanandClaude Sonnet 5 4386a6336a
Playwright Tests / test (push) Canceled after 0s
Let admins create and delete users in Benutzerverwaltung, modernize list
Wire up two previously-unwired stored procedures for the usr module:
- fis_admin_createUserAccount gained the missing @authaccount +
  intranet_admin auth gate, a duplicate-email check, and now returns
  the (possibly auto-generated) password so it can be emailed to the
  new user, mirroring fis_admin_resetUserPassword's pattern.
- fis_admin_delUserAccount gained the same missing auth gate plus a
  guard against an admin deleting their own account.

New /do/usr/create and /do/usr/delete endpoints in
IntranetController.AdminUsers.cs, a "Neuer Benutzer" button and a
"Benutzer löschen" ribbon action in fis.usr.js, and unit tests for the
new welcome-email content (BuildWelcomeEmail).

Also restyle the user list (fis.usr.scss) from a plain bordered table
to a card-style row grid with avatar-initial badges and status pills,
matching the Admin dashboard's visual language.

Documented as ADR 0020 and in the admin-user-management concept doc.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-14 14:51:59 +02:00

35 lines
977 B
Transact-SQL

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[fis_admin_delUserAccount]
@authaccount varchar(5)
,@useraccount_id varchar(5)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @utcnow datetime = GETUTCDATE();
DECLARE @auth smallint = [dbo].[fis_admin_getUserAuth](@authaccount);
IF @auth > 1 AND @authaccount <> @useraccount_id
BEGIN
IF EXISTS (SELECT * FROM [dbo].[fis_useraccounts] WHERE [useraccount_id] = @useraccount_id and [DateDeleted] is null)
BEGIN
UPDATE [dbo].[fis_useraccounts]
SET [UserDeleted] = @authaccount
,[DateDeleted] = @utcnow
WHERE
[useraccount_id] = @useraccount_id;
END
END
SELECT CAST((CASE WHEN NOT EXISTS (SELECT * FROM [dbo].[fis_useraccounts] WHERE [useraccount_id] = @useraccount_id and [DateDeleted] is null) THEN 1 ELSE 0 END) as bit);
END