Commit 022510ad authored by Koosha Khajeh Moogahi's avatar Koosha Khajeh Moogahi Committed by Frédéric Buclin

Bug 555829: Refactor userprefs.cgi to use Bugzilla::User everywhere possible

r/a=LpSolit
parent 5fb38bd7
...@@ -32,8 +32,7 @@ sub DoAccount { ...@@ -32,8 +32,7 @@ sub DoAccount {
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user; my $user = Bugzilla->user;
($vars->{'realname'}) = $dbh->selectrow_array( $vars->{'realname'} = $user->name;
"SELECT realname FROM profiles WHERE userid = ?", undef, $user->id);
if (Bugzilla->params->{'allowemailchange'} if (Bugzilla->params->{'allowemailchange'}
&& $user->authorizer->can_change_email) && $user->authorizer->can_change_email)
...@@ -64,6 +63,9 @@ sub DoAccount { ...@@ -64,6 +63,9 @@ sub DoAccount {
sub SaveAccount { sub SaveAccount {
my $cgi = Bugzilla->cgi; my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
$dbh->bz_start_transaction;
my $user = Bugzilla->user; my $user = Bugzilla->user;
my $oldpassword = $cgi->param('old_password'); my $oldpassword = $cgi->param('old_password');
...@@ -86,12 +88,7 @@ sub SaveAccount { ...@@ -86,12 +88,7 @@ sub SaveAccount {
validate_password($pwd1, $pwd2); validate_password($pwd1, $pwd2);
if ($oldpassword ne $pwd1) { if ($oldpassword ne $pwd1) {
my $cryptedpassword = bz_crypt($pwd1); $user->set_password($pwd1);
$dbh->do(q{UPDATE profiles
SET cryptpassword = ?
WHERE userid = ?},
undef, ($cryptedpassword, $user->id));
# Invalidate all logins except for the current one # Invalidate all logins except for the current one
Bugzilla->logout(LOGOUT_KEEP_CURRENT); Bugzilla->logout(LOGOUT_KEEP_CURRENT);
} }
...@@ -121,10 +118,9 @@ sub SaveAccount { ...@@ -121,10 +118,9 @@ sub SaveAccount {
} }
} }
my $realname = trim($cgi->param('realname')); $user->set_name($cgi->param('realname'));
trick_taint($realname); # Only used in a placeholder $user->update({ keep_session => 1, keep_tokens => 1 });
$dbh->do("UPDATE profiles SET realname = ? WHERE userid = ?", $dbh->bz_commit_transaction;
undef, ($realname, $user->id));
} }
......
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