Skip to content

Commit

Permalink
https://github.com/danieleteti/delphimvcframework/issues/667
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Jun 21, 2023
1 parent 0374d8f commit 17d9afc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ Congratulations to Daniele Teti and all the staff for the excellent work!" -- Ma

- Added support for dotEnv multiline keys - added dotEnv show case
- 🐞 FIX [Issue 664](https://github.com/danieleteti/delphimvcframework/issues/664) Thanks to [MPannier](https://github.com/MPannier)
- 🐞 FIX [Issue 667](https://github.com/danieleteti/delphimvcframework/issues/667)



Expand Down
1 change: 1 addition & 0 deletions samples/concurrency_speed_test/locusttest/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
locust --host http://localhost:8080 --autostart -u 200 -r 100
8 changes: 2 additions & 6 deletions sources/MVCFramework.Middleware.JWT.pas
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ procedure TMVCJWTAuthenticationMiddleware.OnBeforeRouting(AContext: TWebContext;
LPassword := TNetEncoding.URL.Decode(AContext.Request.Headers[FPasswordHeaderName]);

// read from content
if LUsername.IsEmpty then
if LUsername.IsEmpty and not SameText(AContext.Request.ContentMediaType, TMVCMediaType.APPLICATION_JSON) then
begin
LUsername := AContext.Request.ContentParam(FUserNameHeaderName);
LPassword := AContext.Request.ContentParam(FPasswordHeaderName);
Expand All @@ -381,11 +381,7 @@ procedure TMVCJWTAuthenticationMiddleware.OnBeforeRouting(AContext: TWebContext;
// read from json content
if LUsername.IsEmpty then
begin
lJObj := nil;
try
lJObj := TJsonBaseObject.Parse(AContext.Request.Body) as TJsonObject;
except
end;
lJObj := StrToJSONObject(AContext.Request.Body, False);
try
if Assigned(lJObj) then
begin
Expand Down
12 changes: 10 additions & 2 deletions sources/MVCFramework.Serializer.JsonDataObjects.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3673,7 +3673,11 @@ function StrToJSONObject(const AValue: string; ARaiseExceptionOnError: Boolean):
on E: Exception do
begin
lJSON.Free;
raise EMVCDeserializationException.Create('Invalid JSON Object - ' + E.Message);
Result := nil;
if ARaiseExceptionOnError then
begin
raise EMVCDeserializationException.Create('Invalid JSON Object - ' + E.Message);
end;
end;
end;
end;
Expand All @@ -3694,7 +3698,11 @@ function StrToJSONArray(const AValue: string; ARaiseExceptionOnError: Boolean):
on E: Exception do
begin
lJSON.Free;
raise EMVCDeserializationException.Create('Invalid JSON Array - ' + E.Message);
Result := nil;
if ARaiseExceptionOnError then
begin
raise EMVCDeserializationException.Create('Invalid JSON Array - ' + E.Message);
end;
end;
end;
end;
Expand Down

0 comments on commit 17d9afc

Please sign in to comment.