I need to protect some routes, so if a public (non authenticated) user try to access, the web app redirects him to the login screen. I saw the routes & bridges documentation, so I wrote:
$r->add('/player', {bridge=>1, to=>'Login#login'});
$r->add('/player/:tid', 'Player#show');
The login method returns a template that shows the user+pass authentication form.
But, when I try to access to http://..../player/123, it doesn't show the login form. It executes the Login#login, forgets the template returned by this function, and executes Player#show. Is this the expected behaviour?
Now I am thinking on build some plack middleware to check the protected URLs, and redirect to login form to authenticate if needed.
I'd like to know what is the better approach to resolve this use case with Kelp.
Thanks!