[Catalyst] Overwriting/restoring request data
fireartist
catalyst at fireartist.com
Sun Nov 4 22:14:23 GMT 2018
Hi,
If a user sends a request that requires a login, I'd like to persist
their data until they've successfully logged-in, and continue without
them having to re-enter the original data.
Currently, anywhere that requires a login has the following method:
sub auto : Private {
my ( $self, $c ) = @_;
$self->require_login($c);
$c->check_any_user_role(qw( editor admin ));
}
The require_login method in my BaseController.pm returns true if
logged-in, and does detach('/auth/login') if they're not.
The require_login method is an ideal place to grab the Request data,
freeze it with Storable, encrypt_hex it with Crypt::CBC, and stick it in
the stash.
Then, the login action can put that frozen request into a hidden form
field.
I'd also need to store the $c->action->private_path() so I can detach to
the correct place after login.
The part I'm unsure of is how much of the $c->request data to store, and
how to restore it again after a successful login.
Initially I only need to deal with basic post key/value params, however
I do anticipate needing to deal with file uploads in the future.
Has anyone dealt with this scenario already, or have any advice on how
to restore a different Request?
Many thanks,
Carl
More information about the Catalyst
mailing list