From 60900705412d6512db3eb8bae39da50fc5400a7d Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sun, 1 Mar 2009 23:42:51 +0000 Subject: [PATCH] Bug 121601: Have logout display index.cgi, not just a message on relogin.cgi. Patch by Max Kanat-Alexander r=LpSolit, a=LpSolit --- Bugzilla/Auth/Persist/Cookie.pm | 1 + index.cgi | 17 +++++++++++++---- relogin.cgi | 16 +--------------- .../en/default/global/common-links.html.tmpl | 2 +- template/en/default/sidebar.xul.tmpl | 3 ++- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Bugzilla/Auth/Persist/Cookie.pm b/Bugzilla/Auth/Persist/Cookie.pm index 420bad16b0..c533252d33 100644 --- a/Bugzilla/Auth/Persist/Cookie.pm +++ b/Bugzilla/Auth/Persist/Cookie.pm @@ -161,6 +161,7 @@ sub clear_browser_cookies { my $cgi = Bugzilla->cgi; $cgi->remove_cookie('Bugzilla_login'); $cgi->remove_cookie('Bugzilla_logincookie'); + $cgi->remove_cookie('sudo'); } 1; diff --git a/index.cgi b/index.cgi index 89880d1632..660909452e 100755 --- a/index.cgi +++ b/index.cgi @@ -38,12 +38,24 @@ use Bugzilla::Update; # Check whether or not the user is logged in my $user = Bugzilla->login(LOGIN_OPTIONAL); +my $cgi = Bugzilla->cgi; +my $template = Bugzilla->template; +my $vars = {}; + +# And log out the user if requested. We do this first so that nothing +# else accidentally relies on the current login. +if ($cgi->param('logout')) { + Bugzilla->logout(); + $user = Bugzilla->user; + $vars->{'message'} = "logged_out"; + # Make sure that templates or other code doesn't get confused about this. + $cgi->delete('logout'); +} ############################################################################### # Main Body Execution ############################################################################### -my $cgi = Bugzilla->cgi; # Force to use HTTPS unless Bugzilla->params->{'ssl'} equals 'never'. # This is required because the user may want to log in from here. if ($cgi->protocol ne 'https' && Bugzilla->params->{'sslbase'} ne '' @@ -52,9 +64,6 @@ if ($cgi->protocol ne 'https' && Bugzilla->params->{'sslbase'} ne '' $cgi->require_https(Bugzilla->params->{'sslbase'}); } -my $template = Bugzilla->template; -my $vars = {}; - # Return the appropriate HTTP response headers. print $cgi->header(); diff --git a/relogin.cgi b/relogin.cgi index 9d30d7c113..a5cea5f91b 100755 --- a/relogin.cgi +++ b/relogin.cgi @@ -37,7 +37,7 @@ use Date::Format; my $template = Bugzilla->template; my $cgi = Bugzilla->cgi; -my $action = $cgi->param('action') || 'logout'; +my $action = $cgi->param('action'); my $vars = {}; my $target; @@ -184,20 +184,6 @@ elsif ($action eq 'end-sudo') { $vars->{'message'} = 'sudo_ended'; $target = 'global/message.html.tmpl'; } -# Log out the currently logged-in user (this used to be the only thing this did) -elsif ($action eq 'logout') { - # We don't want to remove a random logincookie from the db, so - # call Bugzilla->login(). If we're logged in after this, then - # the logincookie must be correct - Bugzilla->login(LOGIN_OPTIONAL); - - $cgi->remove_cookie('sudo'); - - Bugzilla->logout(); - - $vars->{'message'} = "logged_out"; - $target = 'global/message.html.tmpl'; -} # No valid action found else { Bugzilla->login(LOGIN_OPTIONAL); diff --git a/template/en/default/global/common-links.html.tmpl b/template/en/default/global/common-links.html.tmpl index 6f2c46f468..5c4e9d9a5e 100644 --- a/template/en/default/global/common-links.html.tmpl +++ b/template/en/default/global/common-links.html.tmpl @@ -68,7 +68,7 @@
  • | [% IF user.authorizer.can_logout %] - Log out + Log out [% ELSE %] Logged in as [% END %] diff --git a/template/en/default/sidebar.xul.tmpl b/template/en/default/sidebar.xul.tmpl index 8035c8298b..3df943e5ce 100644 --- a/template/en/default/sidebar.xul.tmpl +++ b/template/en/default/sidebar.xul.tmpl @@ -97,7 +97,8 @@ function normal_keypress_handler( aEvent ) { [%- END %] [%- IF user.authorizer.can_logout %] - + [%- END %] [%- IF user.showmybugslink %] -- 2.47.2