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
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
/// 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
|
||||
@@ -7,19 +11,56 @@ uses
|
||||
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 <> '';
|
||||
@@ -27,8 +68,12 @@ end;
|
||||
|
||||
function TAuthService.Login(const AUser, APass: string): string;
|
||||
begin
|
||||
IncLoginCount;
|
||||
if Validate(AUser + ':' + APass) then
|
||||
Result := 'ok'
|
||||
begin
|
||||
FToken := AUser;
|
||||
Result := 'ok';
|
||||
end
|
||||
else
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user