Mailing List Archive

Overwriting/restoring request data
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@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/
Re: Overwriting/restoring request data [ In reply to ]
Hi Carl ,

why not just use sessions which are available
irrespective of user is logged in or not

$c->session i mean.

Regds

Rajesh Kumar Mallah.
Redgrape Technologies ( https://www.redgrape.tech )
Mobile: 09811255597, Land: 011-49044122
----------------------------------------------------------------------------------------------------------
Opportunities are usually disguised as hard work, so most people don't
recognize them
----------------------------------------------------------------------------------------------------------

----- Original Message -----
| From: "fireartist" <catalyst@fireartist.com>
| To: "Catalyst" <catalyst@lists.scsys.co.uk>
| Sent: Monday, November 5, 2018 3:44:23 AM
| Subject: [Catalyst] Overwriting/restoring request data

| 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@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/



_______________________________________________
List: Catalyst@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/
Re: Overwriting/restoring request data [ In reply to ]
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@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@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/

_______________________________________________
List: Catalyst@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/