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 mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.