Plugin authenticated routes don't have $req->sessionInfo by default
Summary
I would like to modify 2fregisters.tpl
to display some session variables (user login in my case)
The route is declared like this:
$self->addAuthRoute( '2fregisters' => '_displayRegister', ['GET'] );
And displayRegister
renders a HTML template:
return $self->p->sendHtml(
$req,
'2fregisters',
params => { #stuff });
But unlike a lot of other templates, I don't have access to session_*
variables because $req->sessionInfo
is empty
Design proposition
The obvious solution would be to do
$self->p->importHandlerData($req);
at the beginning of displayRegister
to populate $req->sessionInfo
.
But this means that we need to do that in all functions that are executed as authenticated routes if we want session_*
variables to be available in all templates.
I think it would be more interesting if the router could call importHandlerData
automatically when processing an authenticated route. Maybe in PSGI::Try::_run
?
What do you think @guimard? Is there a reason why handler data is not always imported?