Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Redirect if not a User or not logged in

Quote Reply
Redirect if not a User or not logged in
In Modify.pm there is a routine at the very top to check if the user is logged in as follows:

sub handle {
# ---------------------------------------------------
# Determine what to do.
#
my $link_id = $IN->param('LinkID');
if ($CFG->{user_required} and ! $USER) {
print $IN->redirect( Links::redirect_login_url('modify') );
return;
}


If someone is not a user or not logged in, it redirects them to the login page via user.cgi although I cannot find where redirect_login_url is actually located.

Anyway, instead of redirecting them to the login page at user.cgi I want them redirected to a new script that I have called signup.cgi (or to another template name singnup.html) - how can I do this?

Thanks
Quote Reply
Re: [socrates] Redirect if not a User or not logged in In reply to
Hi,

I know this is not a direct answer but have you thought about using Community that provides you with this type of functionality ? Community will give you a sign-up form and users will be redirected to it when they are not authenticated/logged in.

You can also with Community redirect users back to the page they logged in from if you have a sort of mini log-in form on each page, say in a side-bar...

Hope this helps,

John
Significant Media
Post deleted by socrates In reply to

Last edited by:

socrates: Nov 4, 2005, 6:17 PM
Quote Reply
Re: [socrates] Redirect if not a User or not logged in In reply to
redirect_login_url is in Links.pm. There's no easy way to just redirect to different script or template, but you can write a pretty simple plugin to make redirect_login_url return your own url instead of the default. If you take a look at Links.pm, sub redirect_login_url, all it's doing is dispatching the plugin hook redirect_login_url, which will generate a url and return it, which returns it back to Links::Modify::handle (which prints the redirect header).

To not follow that default behaviour write a plugin that hooks into redirect_login_url, and if the first argument (from) is 'modify', return your own url and stop the default code from running (GT::Plugins->action(STOP);.

The plugin would be something like:
Code:
my ($from) = @_;
if ($from eq 'modify') {
GT::Plugins->action(STOP);
return "construct your url here";
}
return @_;

Adrian