Sorry here's the error ...
[Fri May 18 15:48:37 2018] [debug] POST "/auth"
[Fri May 18 15:48:37 2018] [debug] Routing to a callback
[Fri May 18 15:48:37 2018] [error] Failed HS validation at
/srv/ccdapi/temp/jwt.pl line 18.
[Fri May 18 15:48:37 2018] [debug] Template "exception.development.html.ep"
not found
[Fri May 18 15:48:37 2018] [debug] Template "exception.html.ep" not found
[Fri May 18 15:48:37 2018] [debug] Rendering template "mojo/debug.html.ep"
[Fri May 18 15:48:37 2018] [debug] Rendering template "mojo/menubar.html.ep"
[Fri May 18 15:48:37 2018] [debug] Your secret passphrase needs to be
changed
[Fri May 18 15:48:37 2018] [debug] 500 Internal Server Error (0.064189s,
15.579/s)
On Friday, 18 May 2018 15:57:11 UTC-4, Luc Larochelle wrote:
>
> I'm using Mojo::JWT to produde a token and verify authorization on routes
> (using the given token, with the same secret)
>
> Thing is , when the token is invalid, an error is being thrown and the
> application crashes. I'd like to contain the error and deal with it.
>
> What am I missing ? Here's the sample code
>
>
>
> use Mojo::JWT;
> use Mojolicious::Lite;
> use Data::Dumper;
>
> helper check_token => sub {
>
> my $self = shift;
> my $token = $self->req->headers->authorization;
> my $jwt = Mojo::JWT->new(secret => 'mytest');
> return $jwt->decode($token);
>
> };
>
> any '/auth' => sub {
> my $c = shift;
> my $claims = $c->check_token;
>
> if (!($claims)) {
> $c->render(json => {status => "error", data => { message
> => "Please authenticate" }});
> } else {
> $c->render(json => $claims);
> }
>
> };
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.