Add feature, redirect after logout.
This commit is contained in:
parent
476b14f82c
commit
04c902a23e
7 changed files with 73 additions and 6 deletions
|
|
@ -6,4 +6,5 @@
|
||||||
- Added Facebook Auth and FacebookLogin macro.
|
- Added Facebook Auth and FacebookLogin macro.
|
||||||
- Removed the WebGUI statistics program and code.
|
- Removed the WebGUI statistics program and code.
|
||||||
- Prevent Env Macro from being used to access objects in the environment - Thanks to Haarg
|
- 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;
|
return $self->showMessageOnLogin;
|
||||||
}
|
}
|
||||||
elsif ($self->session->form->get('returnUrl')) {
|
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");
|
$self->session->scratch->delete("redirectAfterLogin");
|
||||||
}
|
}
|
||||||
elsif ($self->session->scratch->get("redirectAfterLogin")) {
|
elsif ($self->session->scratch->get("redirectAfterLogin")) {
|
||||||
my $url = $self->session->scratch->delete("redirectAfterLogin");
|
my $url = $self->session->scratch->delete("redirectAfterLogin");
|
||||||
$self->session->response->setRedirect($url);
|
$self->session->response->redirect($url);
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -1283,7 +1283,12 @@ sub www_logout {
|
||||||
|
|
||||||
# Do not allow caching of the logout page (to ensure the page gets requested)
|
# Do not allow caching of the logout page (to ensure the page gets requested)
|
||||||
$self->session->response->setCacheControl( "none" );
|
$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;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -495,6 +495,14 @@ sub definition {
|
||||||
label => $i18n->get( 'redirectAfterLoginUrl label' ),
|
label => $i18n->get( 'redirectAfterLoginUrl label' ),
|
||||||
hoverHelp => $i18n->get( 'redirectAfterLoginUrl description' ),
|
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, {
|
push @fields, {
|
||||||
tab => "user",
|
tab => "user",
|
||||||
name => "showMessageOnLogin",
|
name => "showMessageOnLogin",
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,7 @@ sub setRedirect {
|
||||||
my @params = $self->session->form->param;
|
my @params = $self->session->form->param;
|
||||||
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
|
return undef if ($url eq $self->session->url->page() && scalar(@params) < 1); # prevent redirecting to self
|
||||||
$self->session->log->info("Redirecting to $url");
|
$self->session->log->info("Redirecting to $url");
|
||||||
$self->location($url);
|
$self->redirect($url, $type);
|
||||||
$self->status($type);
|
|
||||||
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
|
$self->session->style->setMeta({"http-equiv"=>"refresh",content=>"0; URL=".$url});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4214,12 +4214,24 @@ LongTruncOk=1</p>
|
||||||
context => q{Label for site setting},
|
context => q{Label for site setting},
|
||||||
},
|
},
|
||||||
|
|
||||||
'showMessageOnLogin description' => {
|
'redirectAfterLoginUrl description' => {
|
||||||
message => q{Users will be redirected to this url after logging in.},
|
message => q{Users will be redirected to this url after logging in.},
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
context => q{Description for site setting},
|
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' => {
|
'showMessageOnLogin label' => {
|
||||||
message => q{Show Message On Login?},
|
message => q{Show Message On Login?},
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
|
|
|
||||||
4
share/upgrades/7.10.24-8.0.0/redirectOnLogout.pl
Normal file
4
share/upgrades/7.10.24-8.0.0/redirectOnLogout.pl
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
use WebGUI::Upgrade::Script;
|
||||||
|
start_step "Adding Redirect After Logout setting";
|
||||||
|
session->setting->add('redirectAfterLogoutUrl');
|
||||||
|
done;
|
||||||
38
t/Auth/RedirectAfterLogoutUrl.t
Normal file
38
t/Auth/RedirectAfterLogoutUrl.t
Normal file
|
|
@ -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;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue