Files
codegraph/Delphi/fixtures/UAuth.pas
T
Olaf Monien dcca22c78f Delphi-Konzept: Reale tree-sitter-pascal AST-Typen, Integration Guide, erweiterte Fixtures
- Alle Docs auf verifizierte AST-Knotentypen aktualisiert (declClass, declIntf, declProc, etc.)
- Scaffold/ entfernt und durch konkreten Integration Guide ersetzt (06-Integration-Guide.md)
- Neue Docs: AST-Referenz (03), NodeKind-Mapping (05), Integration Guide (06)
- Checklist um bekannte Einschränkungen erweitert (with-Statements, .dfm/.fmx, Generics)
- UAuth.pas erweitert: Sichtbarkeitsbereiche, Felder, Properties, Constructor/Destructor
- UTypes.pas neu: Enums, Records, Type-Aliase, Konstanten, Class Methods, verschachtelte Typen
- UnitResolution.md mit konkreten AST-Strukturen aktualisiert
- README.md an neue Architektur-Beschreibung angepasst
2026-02-11 00:17:29 +01:00

82 lines
1.7 KiB
ObjectPascal

/// Unit UAuth: Authentication-Service mit Interface-Implementierung.
/// Testet: uses, interface (mit GUID), Klasse mit Vererbung + Interface,
/// Sichtbarkeitsbereiche (private/public), Felder, Properties,
/// Methoden, Constructor, Destructor, Funktionsaufrufe.
unit UAuth;
interface
uses
System.SysUtils,
System.Classes;
type
/// Interface für Token-Validierung
ITokenValidator = interface
['{11111111-1111-1111-1111-111111111111}']
function Validate(const AToken: string): Boolean;
end;
/// Auth-Service mit Token-Validierung
TAuthService = class(TInterfacedObject, ITokenValidator)
private
FToken: string;
FLoginCount: Integer;
procedure IncLoginCount;
protected
function GetToken: string;
public
constructor Create;
destructor Destroy; override;
function Validate(const AToken: string): Boolean;
function Login(const AUser, APass: string): string;
property Token: string read GetToken;
property LoginCount: Integer read FLoginCount;
end;
implementation
{ TAuthService }
constructor TAuthService.Create;
begin
inherited Create;
FToken := '';
FLoginCount := 0;
end;
destructor TAuthService.Destroy;
begin
FToken := '';
inherited Destroy;
end;
procedure TAuthService.IncLoginCount;
begin
Inc(FLoginCount);
end;
function TAuthService.GetToken: string;
begin
Result := FToken;
end;
function TAuthService.Validate(const AToken: string): Boolean;
begin
Result := AToken <> '';
end;
function TAuthService.Login(const AUser, APass: string): string;
begin
IncLoginCount;
if Validate(AUser + ':' + APass) then
begin
FToken := AUser;
Result := 'ok';
end
else
Result := '';
end;
end.