Files
Fuchs_Intranet/Fuchs_Database/dbo/Functions/fis_admin_authenticate_byID.sql
T
Stefan 10ecdfa2e4 Add Fuchs_Database SSDT project (schema source of truth)
Adds the SQL Server Data Tools project for the fuchs_fds database — tables,
table types, functions and stored procedures that the backend calls (e.g.
fds__getInvoice, fds__merge_bankingtransactions, fds__tt__bankingtransactions,
fds__admin_getReportCatalog, fis_* auth). Build/model caches (bin, obj,
*.dbmdl, *.jfm, *.user) are git-ignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 14:50:54 +02:00

34 lines
1.1 KiB
Transact-SQL

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[fis_admin_authenticate_byID]
(
@useraccount_id varchar(10),
@password nvarchar(20)
)
RETURNS @RET TABLE ( [useraccount_id] varchar(5), [auth] smallint, [name] nvarchar(100) null, [firstname] nvarchar(100) null, [email] varchar(255) NULL, [mobile] varchar(50) null, [functions] varchar(1000), [language] varchar(2), [fullname] nvarchar(255) null, [fullname_rev] nvarchar(255) null)
AS
BEGIN
DECLARE @auth smallint = -1;
DECLARE @name nvarchar(255), @mobile varchar(50), @functions varchar(1000) = '';
IF EXISTS( SELECT 0
FROM [dbo].[fis_useraccounts] as ua
WHERE ua.[DateDeleted] is null AND ua.[DateDisabled] is null
AND [useraccount_id] = @useraccount_id and ISNULL(@useraccount_id, '') <> ''
AND CAST(DECRYPTBYKEY(ua.[password_enc]) as nvarchar(20)) = @password
AND @password <> ''
AND ua.[password_enc] is not null
)
BEGIN
INSERT INTO @RET SELECT * FROM [dbo].[fis_admin_getUserAccount](@useraccount_id);
END
RETURN;
END