summaryrefslogtreecommitdiffstats
path: root/Bugzilla/API/1_0/Resource/User.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/API/1_0/Resource/User.pm')
-rw-r--r--Bugzilla/API/1_0/Resource/User.pm34
1 files changed, 23 insertions, 11 deletions
diff --git a/Bugzilla/API/1_0/Resource/User.pm b/Bugzilla/API/1_0/Resource/User.pm
index a214bd81f..101a70529 100644
--- a/Bugzilla/API/1_0/Resource/User.pm
+++ b/Bugzilla/API/1_0/Resource/User.pm
@@ -53,13 +53,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',
};
@@ -158,8 +156,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;
}
@@ -174,11 +175,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
});
@@ -225,7 +231,7 @@ sub get {
@users = map { filter $params, {
id => as_int($_->id),
real_name => as_string($_->name),
- name => as_email($_->login),
+ name => as_login($_->login),
} } @$in_group;
return { users => \@users };
@@ -277,12 +283,12 @@ sub get {
my $user_info = filter $params, {
id => as_int($user->id),
real_name => as_string($user->name),
- name => as_email($user->login),
- email => as_email($user->email),
+ name => as_login($user->login),
can_login => as_boolean($user->is_enabled ? 1 : 0),
};
if (Bugzilla->user->in_group('editusers')) {
+ $user_info->{email} = as_email($user->email),
$user_info->{email_enabled} = as_boolean($user->email_enabled);
$user_info->{login_denied_text} = as_string($user->disabledtext);
}
@@ -651,6 +657,8 @@ This is the recommended way to create a Bugzilla account.
=item C<email> (string) - the email to send the offer to.
+=item C<login> (string) - the login of the user account.
+
=back
=item B<Returns> (nothing)
@@ -699,6 +707,11 @@ are the same as below.
=item C<email> (string) - The email address for the new user.
+=item C<login> (string) - The login name for the new user.
+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<full_name> (string) B<Optional> - The user's full name. Will
be set to empty if not specified.
@@ -768,7 +781,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 of user to update.
=item C<full_name>
@@ -996,8 +1009,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
@@ -1083,7 +1095,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.