Commit 558994be authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 452519: Fix timezones in emails - Patch by Fré©ric Buclin…

Bug 452519: Fix timezones in emails - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=wicked a=LpSolit
parent 11fa9ce3
...@@ -74,7 +74,7 @@ sub issue_new_user_account_token { ...@@ -74,7 +74,7 @@ sub issue_new_user_account_token {
my ($token, $token_ts) = _create_token(undef, 'account', $login_name); my ($token, $token_ts) = _create_token(undef, 'account', $login_name);
$vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'}; $vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'};
$vars->{'token_ts'} = $token_ts; $vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400);
$vars->{'token'} = $token; $vars->{'token'} = $token;
my $message; my $message;
...@@ -103,10 +103,7 @@ sub IssueEmailChangeToken { ...@@ -103,10 +103,7 @@ sub IssueEmailChangeToken {
$vars->{'oldemailaddress'} = $old_email . $email_suffix; $vars->{'oldemailaddress'} = $old_email . $email_suffix;
$vars->{'newemailaddress'} = $new_email . $email_suffix; $vars->{'newemailaddress'} = $new_email . $email_suffix;
$vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400);
$vars->{'max_token_age'} = MAX_TOKEN_AGE;
$vars->{'token_ts'} = $token_ts;
$vars->{'token'} = $token; $vars->{'token'} = $token;
$vars->{'emailaddress'} = $old_email . $email_suffix; $vars->{'emailaddress'} = $old_email . $email_suffix;
...@@ -151,8 +148,10 @@ sub IssuePasswordToken { ...@@ -151,8 +148,10 @@ sub IssuePasswordToken {
$vars->{'token'} = $token; $vars->{'token'} = $token;
$vars->{'emailaddress'} = $user->email; $vars->{'emailaddress'} = $user->email;
$vars->{'max_token_age'} = MAX_TOKEN_AGE; $vars->{'expiration_ts'} = ctime($token_ts + MAX_TOKEN_AGE * 86400);
$vars->{'token_ts'} = $token_ts; # The user is not logged in (else he wouldn't request a new password).
# So we have to pass this information to the template.
$vars->{'timezone'} = $user->timezone;
my $message = ""; my $message = "";
$template->process("account/password/forgotten-password.txt.tmpl", $template->process("account/password/forgotten-password.txt.tmpl",
...@@ -233,6 +232,9 @@ sub Cancel { ...@@ -233,6 +232,9 @@ sub Cancel {
$vars->{'token'} = $token; $vars->{'token'} = $token;
$vars->{'tokentype'} = $tokentype; $vars->{'tokentype'} = $tokentype;
$vars->{'issuedate'} = $issuedate; $vars->{'issuedate'} = $issuedate;
# The user is probably not logged in.
# So we have to pass this information to the template.
$vars->{'timezone'} = $user->timezone;
$vars->{'eventdata'} = $eventdata; $vars->{'eventdata'} = $eventdata;
$vars->{'cancelaction'} = $cancelaction; $vars->{'cancelaction'} = $cancelaction;
......
...@@ -37,7 +37,7 @@ to [% Param('maintainer') %] if you suspect foul play. ...@@ -37,7 +37,7 @@ to [% Param('maintainer') %] if you suspect foul play.
Token: [% token %] Token: [% token %]
Token Type: [% tokentype %] Token Type: [% tokentype %]
User: [% emailaddress %] User: [% emailaddress %]
Issue Date: [% issuedate %] Issue Date: [% issuedate FILTER time("%Y-%m-%d %H:%M:%S %Z", timezone) %]
Event Data: [% eventdata %] Event Data: [% eventdata %]
Canceled Because: [% PROCESS cancelactionmessage %] Canceled Because: [% PROCESS cancelactionmessage %]
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% expiration_ts = token_ts + (max_token_age * 86400) %]
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
To: [% emailaddress %] To: [% emailaddress %]
Subject: [% terms.Bugzilla %] Change Email Address Request Subject: [% terms.Bugzilla %] Change Email Address Request
...@@ -38,5 +37,5 @@ this request, visit the following link: ...@@ -38,5 +37,5 @@ this request, visit the following link:
[%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=cxlem [%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=cxlem
If you do nothing, the request will lapse after [%+ max_token_age %] days If you do nothing, the request will lapse after [% constants.MAX_TOKEN_AGE %] days
(on [%+ time2str("%B %o, %Y at %H:%M %Z", expiration_ts) %]). (on [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %]).
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% expiration_ts = token_ts + (max_token_age * 86400) %]
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
To: [% emailaddress %] To: [% emailaddress %]
Subject: [% terms.Bugzilla %] Change Email Address Request Subject: [% terms.Bugzilla %] Change Email Address Request
...@@ -43,5 +42,5 @@ this request, visit the following link: ...@@ -43,5 +42,5 @@ this request, visit the following link:
[%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=cxlem [%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=cxlem
If you do nothing, and [%+ newemailaddress %] confirms this request, If you do nothing, and [%+ newemailaddress %] confirms this request,
the change will be made permanent after [%+ max_token_age %] days the change will be made permanent after [% constants.MAX_TOKEN_AGE %] days
(on [%+ time2str("%B %o, %Y at %H:%M %Z", expiration_ts) %]). (on [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %]).
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[%# INTERFACE: [%# INTERFACE:
# token: string. The token to be used in the user account creation. # token: string. The token to be used in the user account creation.
# email: email address of the user account. # email: email address of the user account.
# date: creation date of the token. # expiration_ts: expiration date of the token.
#%] #%]
[% title = BLOCK %]Create a new user account for '[% email FILTER html %]'[% END %] [% title = BLOCK %]Create a new user account for '[% email FILTER html %]'[% END %]
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
title = title title = title
onload = "document.forms['confirm_account_form'].realname.focus();" %] onload = "document.forms['confirm_account_form'].realname.focus();" %]
[% expiration_ts = date + (constants.MAX_TOKEN_AGE * 86400) %]
<div> <div>
To create your account, you must enter a password in the form below. To create your account, you must enter a password in the form below.
Your email address and Real Name (if provided) will be shown with Your email address and Real Name (if provided) will be shown with
...@@ -60,7 +59,7 @@ ...@@ -60,7 +59,7 @@
<p> <p>
This account will not be created if this form is not completed by This account will not be created if this form is not completed by
<u>[%+ time2str("%B %o, %Y at %H:%M %Z", expiration_ts) %]</u>. <u>[% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %]</u>.
</p> </p>
<p> <p>
......
...@@ -15,13 +15,12 @@ ...@@ -15,13 +15,12 @@
[%# INTERFACE: [%# INTERFACE:
# token: random string used to authenticate the transaction. # token: random string used to authenticate the transaction.
# token_ts: creation date of the token. # expiration_ts: expiration date of the token.
# email: email address of the new account. # email: email address of the new account.
#%] #%]
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% expiration_ts = token_ts + (constants.MAX_TOKEN_AGE * 86400) %]
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
To: [% email %] To: [% email %]
Subject: [% terms.Bugzilla %]: confirm account creation Subject: [% terms.Bugzilla %]: confirm account creation
...@@ -31,11 +30,11 @@ X-Bugzilla-Type: admin ...@@ -31,11 +30,11 @@ X-Bugzilla-Type: admin
using your email address ([% email %]). using your email address ([% email %]).
To continue creating an account using this email address, visit the To continue creating an account using this email address, visit the
following link by [%+ time2str("%B %o, %Y at %H:%M %Z", expiration_ts) %]: following link by [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %]:
[%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=request_new_account [%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=request_new_account
If you did not receive this email before [%+ time2str("%B %o, %Y at %H:%M %Z", expiration_ts) %] or If you did not receive this email before [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z") %] or
you wish to create an account using a different email address you can begin you wish to create an account using a different email address you can begin
again by going to: again by going to:
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
[% PROCESS global/variables.none.tmpl %] [% PROCESS global/variables.none.tmpl %]
[% expiration_ts = token_ts + (max_token_age * 86400) %]
From: [% Param('mailfrom') %] From: [% Param('mailfrom') %]
To: [% emailaddress %] To: [% emailaddress %]
Subject: [% terms.Bugzilla %] Change Password Request Subject: [% terms.Bugzilla %] Change Password Request
...@@ -36,6 +35,6 @@ this request, visit the following link: ...@@ -36,6 +35,6 @@ this request, visit the following link:
[%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=cxlpw [%+ urlbase %]token.cgi?t=[% token FILTER url_quote %]&a=cxlpw
If you do nothing, the request will lapse after [%+ max_token_age +%] days (at If you do nothing, the request will lapse after [% constants.MAX_TOKEN_AGE %] days
precisely [%+ time2str("%H:%M on the %o of %B, %Y", expiration_ts) -%]) or when you (on [% expiration_ts FILTER time("%B %e, %Y at %H:%M %Z", timezone) %]) or when you
log in successfully. log in successfully.
...@@ -37,6 +37,7 @@ use Bugzilla::Error; ...@@ -37,6 +37,7 @@ use Bugzilla::Error;
use Bugzilla::Token; use Bugzilla::Token;
use Bugzilla::User; use Bugzilla::User;
use Date::Format;
use Date::Parse; use Date::Parse;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
...@@ -351,7 +352,7 @@ sub request_create_account { ...@@ -351,7 +352,7 @@ sub request_create_account {
my (undef, $date, $login_name) = Bugzilla::Token::GetTokenData($token); my (undef, $date, $login_name) = Bugzilla::Token::GetTokenData($token);
$vars->{'token'} = $token; $vars->{'token'} = $token;
$vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'}; $vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'};
$vars->{'date'} = str2time($date); $vars->{'expiration_ts'} = ctime(str2time($date) + MAX_TOKEN_AGE * 86400);
# When 'ssl' equals 'always' or 'authenticated sessions', # When 'ssl' equals 'always' or 'authenticated sessions',
# we want this form to always be over SSL. # we want this form to always be over SSL.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment