Skip to content

Commit

Permalink
Added free on jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
snakeice committed Apr 18, 2019
1 parent d625d18 commit ae37ed0
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/Horse.JWT.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,38 @@ procedure Middleware(Req: THorseRequest; Res: THorseResponse; Next: TProc);

LValidations := TJOSEConsumerBuilder.NewConsumer.SetVerificationKey(SecretJWT)
.SetSkipVerificationKeyValidation.SetRequireExpirationTime.Build;

LJWT := TJOSEContext.Create(LToken, TJWTClaims);
try

LJWT := TJOSEContext.Create(LToken, TJWTClaims);
try
try
LValidations.ProcessContext(LJWT);
LJSON := LJWT.GetClaims.JSON;
try
LValidations.ProcessContext(LJWT);
LJSON := LJWT.GetClaims.JSON;

if Assigned(SessionClass) then
begin
LSession := SessionClass.Create;
TJson.JsonToObject(LSession, LJSON);
end
else
LSession := LJSON;
if Assigned(SessionClass) then
begin
LSession := SessionClass.Create;
TJson.JsonToObject(LSession, LJSON);
end
else
LSession := LJSON;

THorseHackRequest(Req).SetSession(LSession);
Next();
finally
LSession.Free;
end;
THorseHackRequest(Req).SetSession(LSession);
Next();
finally
LSession.Free;
end;

except
Res.Send('Unauthorized').Status(401);
raise EHorseCallbackInterrupted.Create;
except
Res.Send('Unauthorized').Status(401);
raise EHorseCallbackInterrupted.Create;
end;
finally
LJWT.Free;
end;
finally
LJWT.Free;
LValidations.Free;
end;
end;

Expand Down

0 comments on commit ae37ed0

Please sign in to comment.