1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| procedure TTrainingAdm.XMLCollectionEvents1Authenticate(XMLCollection: IXMLCollection; e: TAuthenticateEventArgs);
var
Database: IDacDatabase;
Session: WideString;
USR_NAME: WideString;
Expiration: TDateTime;
SavePivot: WideString;
begin
SavePivot := Context.GetValue('XMLC_Pivot');
if CompareText(XMLApplication.InitParams.Values['XMLC_SecurityLevel'], 'GUEST') = 0 then
begin
Context.SetValue('XMLC_Authenticated', '1');
Exit;
end;
Database := XMLCollection.GetDatabase('Database');
if Database = nil then
XMLRequest.RaiseError('Cannot find database', 'TTrainingWM.XMLCollectionEvents1Authenticate');
if not Database.GetConnected then
Database.Open;
Database.StartTransaction;
try
try
e.Handled := True;
USR_NAME := Context.GetValue('XMLC_UserName');
Session := Context.GetValue('XMLC_Session');
Context.SetValue('USR_NAME', USR_NAME);
Context.SetValue('USR_SESSION', Session);
XMLCollection.DBExtract('qryUSRSession');
if Context.GetValue('USR_ID') = '' then
begin
Context.SetValue('XMLC_Authenticated', '0');
XMLRequest.RaiseError('XMLC_AUTHENTICATION_REQUIRED', 'TTrainingWM.XMLCollectionEvents1Authenticate');
end;
Expiration := StrToFloatDef(Context.GetValue('USR_EXPIRATION'), 0);
if Expiration < Now then
begin
Context.SetValue('XMLC_Authenticated', '0');
XMLRequest.RaiseError('XMLC_AUTHENTICATION_REQUIRED', 'TTrainingWM.XMLCollectionEvents1Authenticate');
end;
Context.SetValue('XMLC_Authenticated', '1');
// mettre ici le code de gestion des groupes et autorisations (cf Personnaliser l'autorisation)
except
Database.Rollback;
raise;
end;
finally
Context.SetValue('XMLC_Pivot', SavePivot);
Database.Commit;
end;
end; |
Partager