[Catalyst] Re: redirection to the original URI

Fayland Lam fayland at gmail.com
Mon Jan 1 11:49:12 GMT 2007


Thomas Hartman wrote:
> Actually I see now that the location method is mentioned in the code
> 
> http://search.cpan.org/src/SRI/Catalyst-5.61/lib/Catalyst/Response.pm
> 
> Just not in the documentation. Indeed, it seems only to be used by the
> redirect() method.
> 
> Couldn't you just then use Response::redirect here?
> 
> If my understanding is correct, by using features not advertised in
> the interface (ie, the module documentation), it's more likely to be
> broken on upgrade.
> 

well, we used a lot of such code:
return $c->res->redirect('/login') unless ($c->user_exists);
but Catalyst treats redirect inside, so the $c->req->referer may be not 
what u want. we just can't redirect to the referer.

mm, so I guess my solution can handle it correctly.


> 
> 
> 2007/1/1, Thomas Hartman <thomashartman1 at googlemail.com>:
>> Do you mean Response::redirect() rather than Response::location()? I
>> couldn't find anything about the location method in
>>
>> http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/Catalyst/Response.pm 
>>
>>
>> Or is this a newer/older version than what's current on cpan?
>>
>> 2007/1/1, Fayland Lam <fayland at gmail.com>:
>> > Octavian Rasnita wrote:
>> > > Hi,
>> > >
>> > > If the user wants to access a restricted zone and it is redirected to
>> > > the login page, which is the recommended way of redirecting him 
>> back to
>> > > the original URL?
>> > >
>> > > I know that I could create a hidden field in the login form and 
>> put the
>> > > request URL in that field, and after the login, make a redirect to 
>> that
>> > > URL, but I just want to know if there is a more easier way.
>> > >
>> >
>> > well I would put such code in the sub end : Private {
>> >
>> >      if ($c->res->location) {
>> >          # for login using!
>> >          if ($c->res->location =~ /^\/login/) {
>> >              my $location = '/login?referer=/' . $c->req->path;
>> >              $location .= '?' . uri_escape($c->req->uri->query) if
>> > ($c->req->uri->query);
>> >              $c->res->location($location);
>> >          }
>> >          return 1;
>> >      }
>> >
>> > that would be much easier.
>> >
>> > > Thanks.
>> > >
>> > > Octavian
>> > >
>> > >
>> > > _______________________________________________
>> > > List: Catalyst at lists.rawmode.org
>> > > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
>> > > Searchable archive: 
>> http://www.mail-archive.com/catalyst@lists.rawmode.org/
>> > > Dev site: http://dev.catalyst.perl.org/
>> > >
>> >
>> >
>> > --
>> > Fayland Lam // http://www.fayland.org/
>> >
>> > _______________________________________________
>> > List: Catalyst at lists.rawmode.org
>> > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
>> > Searchable archive: 
>> http://www.mail-archive.com/catalyst@lists.rawmode.org/
>> > Dev site: http://dev.catalyst.perl.org/
>> >
>>
> 
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
> 




More information about the Catalyst mailing list