summaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r--Bugzilla/WebService/Bug.pm31
-rw-r--r--Bugzilla/WebService/Bugzilla.pm4
-rw-r--r--Bugzilla/WebService/Group.pm9
-rw-r--r--Bugzilla/WebService/Product.pm4
-rw-r--r--Bugzilla/WebService/Server/JSONRPC.pm7
-rw-r--r--Bugzilla/WebService/Server/XMLRPC.pm8
-rw-r--r--Bugzilla/WebService/User.pm51
7 files changed, 67 insertions, 47 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 2279395a1..d137000a9 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -366,7 +366,7 @@ sub _translate_comment {
my $comment_hash = {
id => $self->type('int', $comment->id),
bug_id => $self->type('int', $comment->bug_id),
- creator => $self->type('email', $comment->author->login),
+ creator => $self->type('login', $comment->author->login),
time => $self->type('dateTime', $comment->creation_ts),
creation_time => $self->type('dateTime', $comment->creation_ts),
is_private => $self->type('boolean', $comment->is_private),
@@ -1308,7 +1308,7 @@ sub _bug_to_hash {
$item{alias} = [ map { $self->type('string', $_) } @{ $bug->alias } ];
}
if (filter_wants $params, 'assigned_to') {
- $item{'assigned_to'} = $self->type('email', $bug->assigned_to->login);
+ $item{'assigned_to'} = $self->type('login', $bug->assigned_to->login);
$item{'assigned_to_detail'} = $self->_user_to_hash($bug->assigned_to, $params, undef, 'assigned_to');
}
if (filter_wants $params, 'blocks') {
@@ -1322,7 +1322,7 @@ sub _bug_to_hash {
$item{component} = $self->type('string', $bug->component);
}
if (filter_wants $params, 'cc') {
- my @cc = map { $self->type('email', $_) } @{ $bug->cc };
+ my @cc = map { $self->type('login', $_) } @{ $bug->cc };
$item{'cc'} = \@cc;
$item{'cc_detail'} = [ map { $self->_user_to_hash($_, $params, undef, 'cc') } @{ $bug->cc_users } ];
}
@@ -1330,7 +1330,7 @@ sub _bug_to_hash {
$item{'creation_time'} = $self->type('dateTime', $bug->creation_ts);
}
if (filter_wants $params, 'creator') {
- $item{'creator'} = $self->type('email', $bug->reporter->login);
+ $item{'creator'} = $self->type('login', $bug->reporter->login);
$item{'creator_detail'} = $self->_user_to_hash($bug->reporter, $params, undef, 'creator');
}
if (filter_wants $params, 'depends_on') {
@@ -1361,7 +1361,7 @@ sub _bug_to_hash {
}
if (filter_wants $params, 'qa_contact') {
my $qa_login = $bug->qa_contact ? $bug->qa_contact->login : '';
- $item{'qa_contact'} = $self->type('email', $qa_login);
+ $item{'qa_contact'} = $self->type('login', $qa_login);
if ($bug->qa_contact) {
$item{'qa_contact_detail'} = $self->_user_to_hash($bug->qa_contact, $params, undef, 'qa_contact');
}
@@ -1433,8 +1433,7 @@ sub _user_to_hash {
my $item = filter $filters, {
id => $self->type('int', $user->id),
real_name => $self->type('string', $user->name),
- name => $self->type('email', $user->login),
- email => $self->type('email', $user->email),
+ name => $self->type('login', $user->login),
}, $types, $prefix;
return $item;
}
@@ -1455,10 +1454,10 @@ sub _attachment_to_hash {
is_patch => $self->type('int', $attach->ispatch),
}, $types, $prefix;
- # creator requires an extra lookup, so we only send them if
- # the filter wants them.
+ # creator requires an extra lookup, so we only send it if
+ # the filter wants it.
if (filter_wants $filters, 'creator', $types, $prefix) {
- $item->{'creator'} = $self->type('email', $attach->attacher->login);
+ $item->{'creator'} = $self->type('login', $attach->attacher->login);
}
if (filter_wants $filters, 'data', $types, $prefix) {
@@ -1490,7 +1489,7 @@ sub _flag_to_hash {
foreach my $field (qw(setter requestee)) {
my $field_id = $field . "_id";
- $item->{$field} = $self->type('email', $flag->$field->login)
+ $item->{$field} = $self->type('login', $flag->$field->login)
if $flag->$field_id;
}
@@ -2575,10 +2574,6 @@ C<string> The 'real' name for this user, if any.
C<string> The user's Bugzilla login.
-=item C<email>
-
-C<string> The user's email address. Currently this is the same value as the name.
-
=back
=back
@@ -2698,7 +2693,11 @@ in Bugzilla B<4.4>.
=item REST API call added in Bugzilla B<5.0>.
-=item In Bugzilla B<5.0>, the following items were added to the bugs return value: C<assigned_to_detail>, C<creator_detail>, C<qa_contact_detail>.
+=item In Bugzilla B<5.0>, the following items were added to the bugs return
+value: C<assigned_to_detail>, C<creator_detail>, C<qa_contact_detail>.
+
+=item Since Bugzilla B<6.0>, the email address of users is private and is no
+longer returned as part of the user detail hash.
=back
diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm
index 67e40a15f..c0df4754f 100644
--- a/Bugzilla/WebService/Bugzilla.pm
+++ b/Bugzilla/WebService/Bugzilla.pm
@@ -62,7 +62,6 @@ use constant PARAMETERS_LOGGED_IN => qw(
defaultseverity
duplicate_or_move_bug_status
emailregexpdesc
- emailsuffix
letsubmitterchoosemilestone
letsubmitterchoosepriority
mailfrom
@@ -75,6 +74,7 @@ use constant PARAMETERS_LOGGED_IN => qw(
resolution_forbidden_with_open_blockers
search_allow_no_criteria
urlbase
+ use_email_as_login
use_see_also
useclassification
usemenuforusers
@@ -417,7 +417,6 @@ A logged-in user can access the following parameters (listed alphabetically):
C<defaultseverity>,
C<duplicate_or_move_bug_status>,
C<emailregexpdesc>,
- C<emailsuffix>,
C<letsubmitterchoosemilestone>,
C<letsubmitterchoosepriority>,
C<mailfrom>,
@@ -430,6 +429,7 @@ A logged-in user can access the following parameters (listed alphabetically):
C<resolution_forbidden_with_open_blockers>,
C<search_allow_no_criteria>,
C<urlbase>,
+ C<use_email_as_login>,
C<use_see_also>,
C<useclassification>,
C<usemenuforusers>,
diff --git a/Bugzilla/WebService/Group.pm b/Bugzilla/WebService/Group.pm
index ec09604c4..a9539f83d 100644
--- a/Bugzilla/WebService/Group.pm
+++ b/Bugzilla/WebService/Group.pm
@@ -210,8 +210,8 @@ sub _get_group_membership {
map {{
id => $self->type('int', $_->id),
real_name => $self->type('string', $_->name),
- name => $self->type('string', $_->login),
- email => $self->type('string', $_->email),
+ name => $self->type('login', $_->login),
+ email => $self->type('email', $_->email),
can_login => $self->type('boolean', $_->is_enabled),
email_enabled => $self->type('boolean', $_->email_enabled),
login_denied_text => $self->type('string', $_->disabledtext),
@@ -282,7 +282,7 @@ name of the group.
=item C<user_regexp>
-C<string> A regular expression. Any user whose Bugzilla username matches
+C<string> A regular expression. Any user whose Bugzilla email address matches
this regular expression will automatically be granted membership in this group.
=item C<is_active>
@@ -553,8 +553,7 @@ C<string> The email address of the user.
=item name
-C<string> The login name of the user. Note that in some situations this is
-different than their email.
+C<string> The login name of the user.
=item can_login
diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm
index 879d8eac1..66bd32808 100644
--- a/Bugzilla/WebService/Product.pm
+++ b/Bugzilla/WebService/Product.pm
@@ -271,9 +271,9 @@ sub _component_to_hash {
description =>
$self->type('string' , $component->description),
default_assigned_to =>
- $self->type('email', $component->default_assignee->login),
+ $self->type('login', $component->default_assignee->login),
default_qa_contact =>
- $self->type('email', $component->default_qa_contact ?
+ $self->type('login', $component->default_qa_contact ?
$component->default_qa_contact->login : ""),
sort_key => # sort_key is returned to match Bug.fields
0,
diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm
index 93d315fde..b488c8de5 100644
--- a/Bugzilla/WebService/Server/JSONRPC.pm
+++ b/Bugzilla/WebService/Server/JSONRPC.pm
@@ -222,8 +222,11 @@ sub type {
utf8::encode($value) if utf8::is_utf8($value);
$retval = encode_base64($value, '');
}
- elsif ($type eq 'email' && Bugzilla->params->{'webservice_email_filter'}) {
- $retval = email_filter($value);
+ elsif ($type eq 'login') {
+ $retval = Bugzilla->params->{'use_email_as_login'} ? email_filter($retval) : "$retval";
+ }
+ elsif ($type eq 'email') {
+ $retval = Bugzilla->user->in_group('editusers') ? "$retval" : '';
}
return $retval;
diff --git a/Bugzilla/WebService/Server/XMLRPC.pm b/Bugzilla/WebService/Server/XMLRPC.pm
index f697f0927..c6461abd6 100644
--- a/Bugzilla/WebService/Server/XMLRPC.pm
+++ b/Bugzilla/WebService/Server/XMLRPC.pm
@@ -35,11 +35,13 @@ BEGIN {
$value = Bugzilla::WebService::Server->datetime_format_outbound($value);
$value =~ s/-//g;
}
+ elsif ($type eq 'login') {
+ $type = 'string';
+ $value = email_filter($value) if Bugzilla->params->{'use_email_as_login'};
+ }
elsif ($type eq 'email') {
$type = 'string';
- if (Bugzilla->params->{'webservice_email_filter'}) {
- $value = email_filter($value);
- }
+ $value = '' unless Bugzilla->user->in_group('editusers');
}
return XMLRPC::Data->type($type)->value($value);
};
diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm
index 079e0782e..d69df5056 100644
--- a/Bugzilla/WebService/User.pm
+++ b/Bugzilla/WebService/User.pm
@@ -43,13 +43,11 @@ use constant PUBLIC_METHODS => qw(
);
use constant MAPPED_FIELDS => {
- email => 'login',
full_name => 'name',
login_denied_text => 'disabledtext',
};
use constant MAPPED_RETURNS => {
- login_name => 'email',
realname => 'full_name',
disabledtext => 'login_denied_text',
};
@@ -67,7 +65,7 @@ sub login {
return $self->_login_to_hash($user);
}
- # Username and password params are required
+ # Login name and password params are required
foreach my $param ("login", "password") {
(defined $params->{$param} || defined $params->{'Bugzilla_' . $param})
|| ThrowCodeError('param_required', { param => $param });
@@ -103,8 +101,11 @@ sub offer_account_by_email {
my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' });
+ my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
+ $login or ThrowCodeError('param_required', { param => 'login' });
+
Bugzilla->user->check_account_creation_enabled;
- Bugzilla->user->check_and_send_account_creation_confirmation($email);
+ Bugzilla->user->check_and_send_account_creation_confirmation($login, $email);
return undef;
}
@@ -119,11 +120,16 @@ sub create {
my $email = trim($params->{email})
|| ThrowCodeError('param_required', { param => 'email' });
+
+ my $login = Bugzilla->params->{use_email_as_login} ? $email : trim($params->{login});
+ $login or ThrowCodeError('param_required', { param => 'login' });
+
my $realname = trim($params->{full_name});
my $password = trim($params->{password}) || '*';
my $user = Bugzilla::User->create({
- login_name => $email,
+ login_name => $login,
+ email => $email,
realname => $realname,
cryptpassword => $password
});
@@ -170,7 +176,7 @@ sub get {
@users = map { filter $params, {
id => $self->type('int', $_->id),
real_name => $self->type('string', $_->name),
- name => $self->type('email', $_->login),
+ name => $self->type('login', $_->login),
} } @$in_group;
return { users => \@users };
@@ -222,12 +228,12 @@ sub get {
my $user_info = filter $params, {
id => $self->type('int', $user->id),
real_name => $self->type('string', $user->name),
- name => $self->type('email', $user->login),
- email => $self->type('email', $user->email),
+ name => $self->type('login', $user->login),
can_login => $self->type('boolean', $user->is_enabled ? 1 : 0),
};
if (Bugzilla->user->in_group('editusers')) {
+ $user_info->{email} = $self->type('email', $user->email),
$user_info->{email_enabled} = $self->type('boolean', $user->email_enabled);
$user_info->{login_denied_text} = $self->type('string', $user->disabledtext);
}
@@ -605,10 +611,15 @@ and real name.
This is the recommended way to create a Bugzilla account.
-=item B<Param>
+=item B<Params>
=over
+=item C<login> (string) - the login name for the new account.
+If the installation has the C<use_email_as_login> parameter switched on, then
+this parameter is ignored, and the value of the C<email> parameter will
+be used as the login name for the new account.
+
=item C<email> (string) - the email to send the offer to.
=back
@@ -659,7 +670,12 @@ are the same as below.
=over
-=item C<email> (string) - The email address for the new user.
+=item C<login> (string) - the login name for the new account.
+If the installation has the C<use_email_as_login> parameter switched on, then
+this parameter is ignored, and the value of the C<email> parameter will
+be used as the login name for the new account.
+
+=item C<email> (string) - The email address for the new account's user.
=item C<full_name> (string) B<Optional> - The user's full name. Will
be set to empty if not specified.
@@ -675,7 +691,7 @@ resetting their password) or by the administrator.
=item B<Returns>
-A hash containing one item, C<id>, the numeric id of the user that was
+A hash containing one item, C<id>, the numeric id of the user account that was
created.
=item B<Errors>
@@ -737,7 +753,7 @@ C<array> Contains ids of user to update.
=item C<names>
-C<array> Contains email/login of user to update.
+C<array> Contains login name of user to update.
=item C<full_name>
@@ -745,8 +761,10 @@ C<string> The new name of the user.
=item C<email>
-C<string> The email of the user. Note that email used to login to bugzilla.
-Also note that you can only update one user at a time when changing the
+C<string> The email address of the user. It may be required that this is the
+same as the login name. If you send different values in that case, the results
+are undefined.
+Note that you can only update one user at a time when changing the
login name / email. (An error will be thrown if you try to update this field
for multiple users at once.)
@@ -967,8 +985,7 @@ C<string> The email address of the user.
=item name
-C<string> The login name of the user. Note that in some situations this is
-different than their email.
+C<string> The login name of the user.
=item can_login
@@ -1054,7 +1071,7 @@ C<string> The CGI parameters for the saved report.
B<Note>: If you are not logged in to Bugzilla when you call this function, you
will only be returned the C<id>, C<name>, and C<real_name> items. If you are
logged in and not in editusers group, you will only be returned the C<id>, C<name>,
-C<real_name>, C<email>, C<can_login>, and C<groups> items. The groups returned are
+C<real_name>, C<can_login>, and C<groups> items. The groups returned are
filtered based on your permission to bless each group.
The C<saved_searches> and C<saved_reports> items are only returned if you are
querying your own account, even if you are in the editusers group.