diff --git a/webtools/litmus/Litmus/Auth.pm b/webtools/litmus/Litmus/Auth.pm index 70280a68b8c..b6200788ec6 100755 --- a/webtools/litmus/Litmus/Auth.pm +++ b/webtools/litmus/Litmus/Auth.pm @@ -47,18 +47,28 @@ our @EXPORT = qw(); my $logincookiename = $Litmus::Config::user_cookiename; sub setCookie { - my $user = shift; + my $user = shift; + my $expires = shift; + + my $user_id = 0; + if ($user) { + $user_id = $user->userid(); + } + + if (!$expires or $expires eq '') { + $expires = '+3d'; + } - my $c = new CGI; - - my $cookie = $c->cookie( - -name => $logincookiename, - -value => $user->userid(), - -domain => $main::ENV{"HTTP_HOST"}, - -expires=>'+3d', - ); - - return $cookie; + my $c = new CGI; + + my $cookie = $c->cookie( + -name => $logincookiename, + -value => $user_id, + -domain => $main::ENV{"HTTP_HOST"}, + -expires => $expires, + ); + + return $cookie; } sub getCookie() { @@ -95,4 +105,19 @@ sub canEdit($) { return $userobj->istrusted(); } +######################################################################### +# logout() +# +# Unset the user's cookie, and return them to the main index. +######################################################################### +sub logout() { + my $c = new CGI; + + my $cookie = Litmus::Auth::setCookie(undef,'-1d'); + return $cookie; +} + + 1; + + diff --git a/webtools/litmus/logout.cgi b/webtools/litmus/logout.cgi new file mode 100755 index 00000000000..bd7b7eb40b7 --- /dev/null +++ b/webtools/litmus/logout.cgi @@ -0,0 +1,55 @@ +#!/usr/bin/perl -w +# -*- mode: cperl; c-basic-offset: 8; indent-tabs-mode: nil; -*- + +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is Litmus. +# +# The Initial Developer of the Original Code is +# the Mozilla Corporation. +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# Chris Cooper +# Zach Lipton +# +# ***** END LICENSE BLOCK ***** + +use strict; +$|++; + +use Litmus; +use Litmus::Auth; + +use CGI; +use diagnostics; + +my $title = "Log out"; + +my $c = new CGI; +my $cookie = Litmus::Auth::logout(); + +print $c->header(-cookie => $cookie); + +my $vars = { + title => $title, + }; + +Litmus->template()->process("logout.tmpl", $vars) || + internalError(Litmus->template()->error()); + + + +exit; diff --git a/webtools/litmus/templates/en/default/global/html_header.tmpl b/webtools/litmus/templates/en/default/global/html_header.tmpl index 66262f12704..7e9c3055064 100644 --- a/webtools/litmus/templates/en/default/global/html_header.tmpl +++ b/webtools/litmus/templates/en/default/global/html_header.tmpl @@ -5,6 +5,10 @@ + [% IF redirect_home %] + + [% END %] + diff --git a/webtools/litmus/templates/en/default/logout.tmpl b/webtools/litmus/templates/en/default/logout.tmpl new file mode 100644 index 00000000000..2947fd3ddb7 --- /dev/null +++ b/webtools/litmus/templates/en/default/logout.tmpl @@ -0,0 +1,18 @@ +[% INCLUDE global/html_header.tmpl redirect_home=1 %] +[% INCLUDE global/litmus_header.tmpl %] + +
+ +[% INCLUDE sidebar/sidebar.tmpl %] + +
+ +

[% title %]

+ You have been successfully logged out of Litmus. + +
+ +
+ +[% INCLUDE global/litmus_footer.tmpl %] +[% INCLUDE global/html_footer.tmpl %] diff --git a/webtools/litmus/templates/en/default/reporting/result_display.tmpl b/webtools/litmus/templates/en/default/reporting/result_display.tmpl index 2ad1390e8ff..d2895aeae12 100644 --- a/webtools/litmus/templates/en/default/reporting/result_display.tmpl +++ b/webtools/litmus/templates/en/default/reporting/result_display.tmpl @@ -69,6 +69,17 @@ Referenced Bugs +[% IF defaultemail %] + +[% ELSE %] + +[% END %] + + -[% IF defaultemail %] - - - -[% ELSE %] - - -[% END %]
+Add bug references: (bug #,bug #,...) + +You must log in before you can add bug references. +
[% IF result.bugs %] Bug IDs: @@ -80,18 +91,6 @@ No bugs on file. [% END %]
-Add bug references: (bug #,bug #,...) -
-You must log in before you can add bug references. -
@@ -141,7 +140,7 @@ Anonymous [% ELSE %] - + No comments. diff --git a/webtools/litmus/templates/en/default/sidebar/widget_login.tmpl b/webtools/litmus/templates/en/default/sidebar/widget_login.tmpl index 67e57f8740f..5a5b9eaf3de 100644 --- a/webtools/litmus/templates/en/default/sidebar/widget_login.tmpl +++ b/webtools/litmus/templates/en/default/sidebar/widget_login.tmpl @@ -3,7 +3,7 @@ [% IF defaultemail %]

Welcome!

-

Log out

+

Log out

[% ELSE %]

Log in

Username: