summaryrefslogtreecommitdiffstats
path: root/token.cgi
diff options
context:
space:
mode:
authorKoosha Khajeh Moogahi <koosha.khajeh@gmail.com>2012-05-18 16:36:12 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-05-18 16:36:12 +0200
commitcb114a086e9d68706f326adcc30b149fb06170d1 (patch)
tree98d0a3f2e75363f912cbe914ce8ac451544ad6b3 /token.cgi
parent7298d3241bea1272ba316c437007d9c07c4ed8b4 (diff)
downloadbugzilla-cb114a086e9d68706f326adcc30b149fb06170d1.tar.gz
bugzilla-cb114a086e9d68706f326adcc30b149fb06170d1.tar.xz
Bug 752303: It is no longer possible to cancel an email address change when this one has already been confirmed
r/a=LpSolit
Diffstat (limited to 'token.cgi')
-rwxr-xr-xtoken.cgi19
1 files changed, 5 insertions, 14 deletions
diff --git a/token.cgi b/token.cgi
index 5f647edb3..9a6a0de88 100755
--- a/token.cgi
+++ b/token.cgi
@@ -193,7 +193,6 @@ sub confirmChangeEmail {
sub changeEmail {
my ($userid, $eventdata, $token) = @_;
my $dbh = Bugzilla->dbh;
-
my ($old_email, $new_email) = split(/:/,$eventdata);
# Check the user entered the correct old email address
@@ -208,21 +207,15 @@ sub changeEmail {
ThrowUserError("account_exists", { email => $new_email } );
}
- # Update the user's login name in the profiles table and delete the token
- # from the tokens table.
$dbh->bz_start_transaction();
- $dbh->do(q{UPDATE profiles
- SET login_name = ?
- WHERE userid = ?},
- undef, ($new_email, $userid));
+ my $user = Bugzilla::User->check({ id => $userid });
+ # Update the user's login name in the profiles table.
+ $user->set_login($new_email);
+ $user->update({ keep_session => 1, keep_tokens => 1 });
delete_token($token);
$dbh->do(q{DELETE FROM tokens WHERE userid = ?
AND tokentype = 'emailnew'}, undef, $userid);
- # The email address has been changed, so we need to rederive the groups
- my $user = new Bugzilla::User($userid);
- $user->derive_regexp_groups;
-
$dbh->bz_commit_transaction();
# Return HTTP response headers.
@@ -250,9 +243,7 @@ sub cancelChangeEmail {
# check to see if it has been altered
if ($user->login ne $old_email) {
$user->set_login($old_email);
- $user->update();
- # email has changed, so rederive groups
- $user->derive_regexp_groups;
+ $user->update({ keep_session => 1 });
$vars->{'message'} = "email_change_canceled_reinstated";
}