summaryrefslogtreecommitdiffstats
path: root/userprefs.cgi
diff options
context:
space:
mode:
authorgerv%gerv.net <>2002-10-06 20:52:28 +0200
committergerv%gerv.net <>2002-10-06 20:52:28 +0200
commitb8851cdd5c15e0d21543d9fe08159b9ced8c950f (patch)
treece1c674c28c6491d3a86e3afb182963737666e2d /userprefs.cgi
parentf50efb95e1c7462699f1179d0a62b1ee7118e67e (diff)
downloadbugzilla-b8851cdd5c15e0d21543d9fe08159b9ced8c950f.tar.gz
bugzilla-b8851cdd5c15e0d21543d9fe08159b9ced8c950f.tar.xz
Bug 163114 - Templatise all calls to DisplayError. Patch D (the last one). Patch by gerv; r=burnus.
Diffstat (limited to 'userprefs.cgi')
-rwxr-xr-xuserprefs.cgi41
1 files changed, 12 insertions, 29 deletions
diff --git a/userprefs.cgi b/userprefs.cgi
index 3e4011201..d7ad1760d 100755
--- a/userprefs.cgi
+++ b/userprefs.cgi
@@ -92,29 +92,19 @@ sub SaveAccount {
my $old = SqlQuote($::FORM{'Bugzilla_password'});
SendSQL("SELECT cryptpassword FROM profiles WHERE userid = $userid");
my $oldcryptedpwd = FetchOneColumn();
- if (!$oldcryptedpwd) {
- DisplayError("I was unable to retrieve your old password from the database.");
- exit;
- }
+ $oldcryptedpwd || ThrowCodeError("unable_to_retrieve_password");
+
if (crypt($::FORM{'Bugzilla_password'}, $oldcryptedpwd) ne
$oldcryptedpwd)
{
- DisplayError("You did not enter your old password correctly.");
- exit;
+ ThrowUserError("old_password_incorrect");
}
if ($pwd1 ne "" || $pwd2 ne "")
{
- if ($pwd1 ne $pwd2) {
- DisplayError("The two passwords you entered did not match.");
- exit;
- }
- if ($::FORM{'new_password1'} eq '') {
- DisplayError("You must enter a new password.");
- exit;
- }
- my $passworderror = ValidatePassword($pwd1);
- (DisplayError($passworderror) && exit) if $passworderror;
+ ($pwd1 eq $pwd2) || ThrowUserError("passwords_dont_match");
+ $::FORM{'new_password1'} || ThrowUserError("new_password_missing");
+ ValidatePassword($pwd1);
my $cryptedpassword = SqlQuote(Crypt($pwd1));
SendSQL("UPDATE profiles
@@ -130,27 +120,20 @@ sub SaveAccount {
my $new_login_name = trim($::FORM{'new_login_name'});
if($old_login_name ne $new_login_name) {
- if( $::FORM{'Bugzilla_password'} eq "") {
- DisplayError("You must enter your old password to
- change email address.");
- exit;
- }
+ $::FORM{'Bugzilla_password'}
+ || ThrowCodeError("old_password_required");
use Token;
# Block multiple email changes for the same user.
if (Token::HasEmailChangeToken($userid)) {
- DisplayError("Email change already in progress;
- please check your email.");
- exit;
+ ThrowUserError("email_change_in_progress");
}
# Before changing an email address, confirm one does not exist.
CheckEmailSyntax($new_login_name);
trick_taint($new_login_name);
- if (!ValidateNewUser($new_login_name)) {
- DisplayError("Account $new_login_name already exists");
- exit;
- }
+ ValidateNewUser($new_login_name)
+ || ThrowUserError("account_exists", {email => $new_login_name});
Token::IssueEmailChangeToken($userid,$old_login_name,
$new_login_name);
@@ -325,7 +308,7 @@ sub SaveFooter {
"AND name = " . SqlQuote($name));
}
} else {
- DisplayError("Hmm, the $name query seems to have gone away.");
+ ThrowUserError("missing_query", {queryname => $name});
}
}
SendSQL("UPDATE profiles SET mybugslink = " .