summaryrefslogtreecommitdiffstats
path: root/relogin.cgi
diff options
context:
space:
mode:
authorkarl%kornel.name <>2005-11-05 01:11:27 +0100
committerkarl%kornel.name <>2005-11-05 01:11:27 +0100
commit1afe548f9e830bcace4e06d3441bdd4b41c8d11a (patch)
treee25c39859529d8c72e85a33007d1c22877d6414a /relogin.cgi
parent4c7f4b10f22b3ad45db793ef4eb0e4ab1aef49e0 (diff)
downloadbugzilla-1afe548f9e830bcace4e06d3441bdd4b41c8d11a.tar.gz
bugzilla-1afe548f9e830bcace4e06d3441bdd4b41c8d11a.tar.xz
Bug 312439: The user being impersonated has "moral" rights to keep informed - Patch by A. Karl Kornel <karl@kornel.name> r=LpSolit a=justdave
Diffstat (limited to 'relogin.cgi')
-rwxr-xr-xrelogin.cgi31
1 files changed, 24 insertions, 7 deletions
diff --git a/relogin.cgi b/relogin.cgi
index a8ebd18f4..8c4517f0c 100755
--- a/relogin.cgi
+++ b/relogin.cgi
@@ -23,11 +23,12 @@
# A. Karl Kornel <karl@kornel.name>
use strict;
-
use lib qw(.);
+
+require "globals.pl";
+
use Bugzilla;
-use Bugzilla::Auth::Login::WWW;
-use Bugzilla::CGI;
+use Bugzilla::BugMail;
use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::User;
@@ -70,7 +71,7 @@ if ($action eq 'sudo') {
}
# Show the sudo page
- $vars->{'will_logout'} = 1 if Bugzilla::Auth::Login::WWW->can_logout;
+ $vars->{'will_logout'} = $user->get_flag('can_logout');
$target = 'admin/sudo.html.tmpl';
}
# transition-sudo: Validate target, logout user, and redirect for session start
@@ -113,11 +114,16 @@ elsif ($action eq 'sudo-transition') {
ThrowUserError('sudo_protected', { login => $target_user->login });
}
- # Log out and Redirect user to the new page
+ # If we have a reason passed in, keep it under 200 characters
+ my $reason = $cgi->param('reason') || '';
+ $reason = substr($reason, $[, 200);
+ my $reason_string = '&reason=' . url_quote($reason);
+
+ # Log out and redirect user to the new page
Bugzilla->logout();
$target = 'relogin.cgi';
print $cgi->redirect($target . '?action=begin-sudo&target_login=' .
- url_quote($target_user->login));
+ url_quote($target_user->login) . $reason_string);
exit;
}
# begin-sudo: Confirm login and start sudo session
@@ -161,6 +167,10 @@ elsif ($action eq 'begin-sudo') {
ThrowUserError('sudo_protected', { login => $target_user->login });
}
+ # If we have a reason passed in, keep it under 200 characters
+ my $reason = $cgi->param('reason') || '';
+ $reason = substr($reason, $[, 200);
+
# Calculate the session expiry time (T + 6 hours)
my $time_string = time2str('%a, %d-%b-%Y %T %Z', time+(6*60*60), 'GMT');
@@ -174,7 +184,14 @@ elsif ($action eq 'begin-sudo') {
Bugzilla->sudo_request($target_user, Bugzilla->user);
# NOTE: If you want to log the start of an sudo session, do it here.
-
+
+ # Go ahead and send out the message now
+ my $message;
+ $template->process('email/sudo.txt.tmpl',
+ { reason => $reason },
+ \$message);
+ Bugzilla::BugMail::MessageToMTA($message);
+
$vars->{'message'} = 'sudo_started';
$vars->{'target'} = $target_user->login;
$target = 'global/message.html.tmpl';