summaryrefslogtreecommitdiffstats
path: root/userprefs.cgi
diff options
context:
space:
mode:
authorKoosha Khajeh Moogahi <koosha.khajeh@gmail.com>2012-05-28 14:16:25 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-05-28 14:16:25 +0200
commit022510ad4a5e17b7322709d173535c230b572b09 (patch)
tree3d51a29c644a59528343808774c6ff7e5ffd8e50 /userprefs.cgi
parent5fb38bd7342c69a567b73dcd15352cde5ea97f71 (diff)
downloadbugzilla-022510ad4a5e17b7322709d173535c230b572b09.tar.gz
bugzilla-022510ad4a5e17b7322709d173535c230b572b09.tar.xz
Bug 555829: Refactor userprefs.cgi to use Bugzilla::User everywhere possible
r/a=LpSolit
Diffstat (limited to 'userprefs.cgi')
-rwxr-xr-xuserprefs.cgi20
1 files changed, 8 insertions, 12 deletions
diff --git a/userprefs.cgi b/userprefs.cgi
index e527b1489..1b6347456 100755
--- a/userprefs.cgi
+++ b/userprefs.cgi
@@ -32,8 +32,7 @@ sub DoAccount {
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
- ($vars->{'realname'}) = $dbh->selectrow_array(
- "SELECT realname FROM profiles WHERE userid = ?", undef, $user->id);
+ $vars->{'realname'} = $user->name;
if (Bugzilla->params->{'allowemailchange'}
&& $user->authorizer->can_change_email)
@@ -64,6 +63,9 @@ sub DoAccount {
sub SaveAccount {
my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
+
+ $dbh->bz_start_transaction;
+
my $user = Bugzilla->user;
my $oldpassword = $cgi->param('old_password');
@@ -86,12 +88,7 @@ sub SaveAccount {
validate_password($pwd1, $pwd2);
if ($oldpassword ne $pwd1) {
- my $cryptedpassword = bz_crypt($pwd1);
- $dbh->do(q{UPDATE profiles
- SET cryptpassword = ?
- WHERE userid = ?},
- undef, ($cryptedpassword, $user->id));
-
+ $user->set_password($pwd1);
# Invalidate all logins except for the current one
Bugzilla->logout(LOGOUT_KEEP_CURRENT);
}
@@ -121,10 +118,9 @@ sub SaveAccount {
}
}
- my $realname = trim($cgi->param('realname'));
- trick_taint($realname); # Only used in a placeholder
- $dbh->do("UPDATE profiles SET realname = ? WHERE userid = ?",
- undef, ($realname, $user->id));
+ $user->set_name($cgi->param('realname'));
+ $user->update({ keep_session => 1, keep_tokens => 1 });
+ $dbh->bz_commit_transaction;
}