mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
This commit is contained in:
parent
c2d3cbc859
commit
78ef7c01a9
@ -703,6 +703,8 @@ The current beta release is named 3.2.2-nitrogen. If you want to stay on the-edg
|
||||
|
||||
- Fix https://github.com/danieleteti/delphimvcframework/issues/526 (Thanks to [David Moorhouse](https://github.com/fastbike))
|
||||
|
||||
- Fix https://github.com/danieleteti/delphimvcframework/issues/544 (Thanks to [David Moorhouse](https://github.com/fastbike))
|
||||
|
||||
- Fix https://github.com/danieleteti/delphimvcframework/issues/542 (Thanks to [Lamberto Lodi](https://github.com/llodi-csw) for the hints)
|
||||
|
||||
- Fixed *fileupload* sample
|
||||
|
@ -955,7 +955,7 @@ type
|
||||
function ExecuteAction(const ASender: TObject; const ARequest: TWebRequest;
|
||||
const AResponse: TWebResponse): Boolean; virtual;
|
||||
public
|
||||
class function GetCurrentSession(const ASessionTimeout: Integer; const ASessionId: string;
|
||||
class function GetCurrentSession(const ASessionId: string;
|
||||
const ARaiseExceptionIfExpired: Boolean = True): TWebSession; static;
|
||||
class function ExtractSessionIdFromWebRequest(const AWebRequest: TWebRequest): string; static;
|
||||
class function SendSessionCookie(const AContext: TWebContext): string; overload; static;
|
||||
@ -1907,8 +1907,7 @@ procedure TWebContext.BindToSession(const ASessionId: string);
|
||||
begin
|
||||
if not Assigned(FWebSession) then
|
||||
begin
|
||||
FWebSession := TMVCEngine.GetCurrentSession(StrToInt64(FConfig[TMVCConfigKey.SessionTimeout]),
|
||||
ASessionId, False);
|
||||
FWebSession := TMVCEngine.GetCurrentSession(ASessionId, False);
|
||||
if not Assigned(FWebSession) then
|
||||
raise EMVCException.Create('Invalid SessionID');
|
||||
FWebSession.MarkAsUsed;
|
||||
@ -2070,7 +2069,7 @@ function TWebContext.GetWebSession: TWebSession;
|
||||
begin
|
||||
if not Assigned(FWebSession) then
|
||||
begin
|
||||
FWebSession := TMVCEngine.GetCurrentSession(StrToInt64(FConfig[TMVCConfigKey.SessionTimeout]),
|
||||
FWebSession := TMVCEngine.GetCurrentSession(
|
||||
TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest), False);
|
||||
if not Assigned(FWebSession) then
|
||||
SessionStart
|
||||
@ -2148,8 +2147,17 @@ begin
|
||||
|
||||
TMonitor.Enter(GlobalSessionList);
|
||||
try
|
||||
SId := TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest);
|
||||
SID := SessionId;
|
||||
if (SId = '') and (ARaiseExceptionIfExpired) then
|
||||
begin
|
||||
raise EMVCSessionExpiredException.Create('Session not started');
|
||||
end;
|
||||
//SId := TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest);
|
||||
GlobalSessionList.Remove(SId);
|
||||
if SId <> '' then
|
||||
begin
|
||||
FWebSession := nil;
|
||||
end;
|
||||
finally
|
||||
TMonitor.Exit(GlobalSessionList);
|
||||
end;
|
||||
@ -2488,7 +2496,7 @@ begin
|
||||
begin
|
||||
Log.ErrorFmt('[%s] %s (Custom message: "%s")', [ESess.Classname, ESess.Message,
|
||||
ESess.DetailedMessage], LOGGERPRO_TAG);
|
||||
lContext.SessionStop(False);
|
||||
lContext.SessionStop;
|
||||
lSelectedController.ResponseStatus(ESess.HTTPErrorCode);
|
||||
lSelectedController.Render(ESess);
|
||||
end;
|
||||
@ -2894,8 +2902,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TMVCEngine.GetCurrentSession(const ASessionTimeout: Integer;
|
||||
const ASessionId: string; const ARaiseExceptionIfExpired: Boolean): TWebSession;
|
||||
class function TMVCEngine.GetCurrentSession(const ASessionId: string; const ARaiseExceptionIfExpired: Boolean): TWebSession;
|
||||
var lSessionList: TObjectDictionary<string, TWebSession>;
|
||||
begin
|
||||
Result := nil;
|
||||
@ -2932,8 +2939,7 @@ end;
|
||||
|
||||
function TMVCEngine.GetSessionBySessionId(const ASessionId: string): TWebSession;
|
||||
begin
|
||||
Result := TMVCEngine.GetCurrentSession(StrToInt64(Config[TMVCConfigKey.SessionTimeout]),
|
||||
ASessionId, False);
|
||||
Result := TMVCEngine.GetCurrentSession(ASessionId, False);
|
||||
if Assigned(Result) then
|
||||
Result.MarkAsUsed;
|
||||
end;
|
||||
|
@ -553,7 +553,7 @@ procedure TTestServerController.Logout;
|
||||
begin
|
||||
if not Context.SessionStarted then
|
||||
raise EMVCException.Create('Session not available');
|
||||
Context.SessionStop(false);
|
||||
Context.SessionStop;
|
||||
if Context.SessionStarted then
|
||||
raise EMVCException.Create('Session still available');
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user