I see two potential problems in your code.
1. Do not use the redirect method of the CGI.pm object from withing
CGI::App to do a redirect. Use something similar to the code below.
$self->header_type( "redirect" );
$self->header_props( -uri => $redirect_url );
2. Be sure to indicate at least the relative path to your cgi script.
Unless you have configured your web server to execut scripts from your
document root, you'll want to add prepend the cgi directory to you
script. Something like this would work with the two lines above.
my $redirect_url = "cgi-bin/login.pl"
Happy refactoring!
-john
PS My experience has shown that Login should be separate module.
Authentication can be built into your application as an optional base
class. This is of course if you are not implementing Authorization with
the web server. =)
--- Tim Howell <suppressed> wrote:
> I'm in the process of refactoring one of my CGI::Apps to separate
> login and permissions code so that it can be used by several apps.
> I'm trying to use redirect() to send a user to the login app if they
> try to access one of the other apps before logging in. With this
> code:
>
> return $cgi_query->redirect("login.pl");
>
> I get this error in the browser:
>
> Status: 302 Moved location: login.pl
>
> Apparently redirect() doesn't work quite as I expected.
>
> Anyone see what I need to do differently?
>
> Thanks! =)
>
> --TWH
>
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.