From dfd80def949c4a38e8623b8d9f32409cd42fb11b Mon Sep 17 00:00:00 2001 From: Daniele Teti Date: Sun, 10 Nov 2024 22:30:56 +0100 Subject: [PATCH] In TempaltePro Templates there is a variable "LoggedUserName" which is always aligned to Context.LoggedUser.UserName --- sources/MVCFramework.View.Renderers.TemplatePro.pas | 1 + sources/MVCFramework.pas | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sources/MVCFramework.View.Renderers.TemplatePro.pas b/sources/MVCFramework.View.Renderers.TemplatePro.pas index bffb8df1..8b272bf6 100644 --- a/sources/MVCFramework.View.Renderers.TemplatePro.pas +++ b/sources/MVCFramework.View.Renderers.TemplatePro.pas @@ -180,6 +180,7 @@ begin begin lCompiledTemplate.SetData(lPair.Key, ViewModel[lPair.Key]); end; + lCompiledTemplate.SetData('LoggedUserName', WebContext.LoggedUser.UserName); end; lCompiledTemplate.AddFilter('json', DumpAsJSONString); lCompiledTemplate.AddFilter('count', GetDataSetOrObjectListCount); diff --git a/sources/MVCFramework.pas b/sources/MVCFramework.pas index 7b6a0231..783022ec 100644 --- a/sources/MVCFramework.pas +++ b/sources/MVCFramework.pas @@ -513,11 +513,11 @@ type FCustomData: TMVCCustomData; procedure SetLoggedSince(const AValue: TDateTime); procedure SetCustomData(const Value: TMVCCustomData); + function GetIsValid: Boolean; public constructor Create; destructor Destroy; override; - function IsValid: Boolean; procedure Clear; procedure SaveToSession(const AWebSession: TMVCWebSession); @@ -528,6 +528,7 @@ type property LoggedSince: TDateTime read FLoggedSince write SetLoggedSince; property Realm: string read FRealm write FRealm; property CustomData: TMVCCustomData read FCustomData write SetCustomData; + property IsValid: Boolean read GetIsValid; end; TWebContext = class @@ -2131,7 +2132,7 @@ begin inherited Destroy; end; -function TUser.IsValid: Boolean; +function TUser.GetIsValid: Boolean; begin Result := (not UserName.IsEmpty) and (LoggedSince > 0); end;