Skip to content
Permalink
Browse files

Add feature, redirect after logout.

  • Loading branch information...
perlDreamer committed Feb 25, 2012
1 parent 476b14f commit 04c902a23e092129c320155d5667be6582dc94c2
@@ -6,4 +6,5 @@
- Added Facebook Auth and FacebookLogin macro.
- Removed the WebGUI statistics program and code.
- Prevent Env Macro from being used to access objects in the environment - Thanks to Haarg
- added: Redirect on Logout setting

@@ -1001,12 +1001,12 @@ sub www_createAccountSave {
return $self->showMessageOnLogin;
}
elsif ($self->session->form->get('returnUrl')) {
$self->session->response->setRedirect( $self->session->form->get('returnUrl') );
$self->session->response->redirect( $self->session->form->get('returnUrl') );
$self->session->scratch->delete("redirectAfterLogin");
}
elsif ($self->session->scratch->get("redirectAfterLogin")) {
my $url = $self->session->scratch->delete("redirectAfterLogin");
$self->session->response->setRedirect($url);
$self->session->response->redirect($url);
return undef;
}
else {
@@ -1283,7 +1283,12 @@ sub www_logout {

# Do not allow caching of the logout page (to ensure the page gets requested)
$self->session->response->setCacheControl( "none" );


if ( $self->session->setting->get("redirectAfterLogoutUrl") ) {
$self->session->log->warn("redirecting to: ".$self->session->setting->get("redirectAfterLogoutUrl"));
$self->session->response->setRedirect($self->session->setting->get("redirectAfterLogoutUrl"));
}

return undef;
}

@@ -495,6 +495,14 @@ sub definition {
label => $i18n->get( 'redirectAfterLoginUrl label' ),
hoverHelp => $i18n->get( 'redirectAfterLoginUrl description' ),
};
push @fields, {
tab => "user",
name => "redirectAfterLogoutUrl",
fieldType => "url",
defaultValue => $setting->get('redirectAfterLogoutUrl'),
label => $i18n->get( 'redirectAfterLogoutUrl label' ),
hoverHelp => $i18n->get( 'redirectAfterLogoutUrl description' ),
};
push @fields, {
tab => "user",
name => "showMessageOnLogin",
@@ -176,8 +176,7 @@ sub setRedirect {
my @params = $self->session->form->param;
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
$self->session->log->info("Redirecting to $url");
$self->location($url);
$self->status($type);
$self->redirect($url, $type);
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
}

@@ -4214,12 +4214,24 @@ LongTruncOk=1</p>
context => q{Label for site setting},
},

'showMessageOnLogin description' => {
'redirectAfterLoginUrl description' => {
message => q{Users will be redirected to this url after logging in.},
lastUpdated => 0,
context => q{Description for site setting},
},

'redirectAfterLogoutUrl label' => {
message => q{Redirect After Logout Url},
lastUpdated => 0,
context => q{Label for site setting},
},

'redirectAfterLogoutUrl description' => {
message => q{Users will be redirected to this url after logging out.},
lastUpdated => 0,
context => q{Description for site setting},
},

'showMessageOnLogin label' => {
message => q{Show Message On Login?},
lastUpdated => 0,
@@ -0,0 +1,4 @@
use WebGUI::Upgrade::Script;
start_step "Adding Redirect After Logout setting";
session->setting->add('redirectAfterLogoutUrl');
done;
@@ -0,0 +1,38 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------

# Test Auth::LDAP to make sure it works with both ldap and ldaps
#
#

use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;

#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;

my $user = WebGUI::User->create($session);
WebGUI::Test->addToCleanup($user);

$session->setting->set('redirectAfterLogoutUrl');
$user->authInstance->www_logout;
is $session->response->redirect, undef, 'no redirect set on logout';

$session->setting->set('redirectAfterLogoutUrl', '/other_page');
$user->authInstance->www_logout;
is $session->response->redirect, '/other_page', 'redirect set on logout';

done_testing;

0 comments on commit 04c902a

Please sign in to comment.
You can’t perform that action at this time.