Skip to content

Conversation

@kabiri
Copy link
Contributor

@kabiri kabiri commented Dec 22, 2025

I added two methods, SkipWhen and SkipRouteMethods, to the source code to define exceptions for JWT token validation on routes.

Example :
THorse.Use(
HorseJWT('xxxxxxxxx',
THorseJWTConfig.New
.SessionClass(TUserSession)
.SkipWhen(
function(const Route: String; const MethodType: TMethodType): Boolean
begin
if ((Route = Controller.Guest.Route) and (MethodType = TMethodType.mtPost)) then
Exit(True);
if ((Route = Controller.Guest.Route) and (MethodType = TMethodType.mtGet)) then
Result := False;
end
)
.SkipRouteMethods([
TSkipRouteMethod.Create(Controller.Login.Route,TMethodType.mtPost)
])
);

I added two methods, SkipWhen and SkipRouteMethods, to the source code to define exceptions for JWT token validation on routes.

Example :
  THorse.Use(
    HorseJWT('xxxxxxxxx',
      THorseJWTConfig.New
        .SessionClass(TUserSession)
        .SkipWhen(
          function(const Route: String; const MethodType: TMethodType): Boolean
          begin
            if ((Route = Controller.Guest.Route) and (MethodType = TMethodType.mtPost)) then
              Exit(True);
            if ((Route = Controller.Guest.Route) and (MethodType = TMethodType.mtGet)) then
              Result := False;
          end
        )
        .SkipRouteMethods([
          TSkipRouteMethod.Create(Controller.Login.Route,TMethodType.mtPost)
        ])
  );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant