[Catalyst] Overwriting/restoring request data

Samuel Kaufman samuel.c.kaufman at gmail.com
Fri Nov 9 01:12:31 GMT 2018


Sorry for the delayed response, this mailing list has been pretty slow
compared to #catalyst on irc. That said if you are using
https://metacpan.org/pod/Catalyst::Plugin::Authentication for login
I'd recommend storing information in the session.
I'm not 100% sure the session will not be rotated once you
authenticate the user but that should be easy to test; but what you
are asking is typical information that would be stored in the session,
taking care not to store too much info in there size-wise.
On Sun, Nov 4, 2018 at 5:16 PM fireartist <catalyst at fireartist.com> wrote:
>
> 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
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list