Gossamer Forum
Home : Products : Others : Gossamer Community :

redirect if not logged in...

Quote Reply
redirect if not logged in...
I'm creating a plugin for community. I use one PRE hook "web_user_home" so that I can have community.cgi?do=whatever...

Obviously this will check if the user is logged-in, and it works fine, but it will not automatically redirect to the page it was trying to get to before, after the login...

Code:
unless ($user and $IN->cookie($CFG->{session_cookie_name_session})) {
return Community::Web::User::user_login();
}

So I figured this borrowed code would work instead...

Code:

if (! $user) {
my $url = $CFG->{path_cgi_url} . '?' . $IN->query_string;
my $redirect_url = comm_login_url( return_to => $url );
GT::Plugins->action (STOP);
print $IN->redirect($redirect_url);
return;
}

But no, it just gives an internal server error. It is as if it loops for a second before dying. Any ideas?

I know it doesn't seem like a bid deal, but it has been driving me crazy to figure out what the problem is.

Note: (I have already imported all of my global variables etc.)

Thanks,

- Jonathan
Quote Reply
Re: [jdgamble] redirect if not logged in... In reply to
Hi,

Try running it from SSH.

Code:
cd /path/to/whjere/community.cgi
perl community.cgi 'do=whatever'

You should see a bit more info then (i.e redirect codes, etc) ..

Doesn't look like your code should fail .. so may be just something silly =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!