Bugzilla::Webservice::User - The User Account and Login API
This part of the Bugzilla API allows you to create User Accounts and log in/out using an existing account.
See Bugzilla::WebService for a description of how parameters are passed, and what STABLE, UNSTABLE, and EXPERIMENTAL mean.
Although the data input and output is the same for JSONRPC, XMLRPC and REST, the directions for how to access the data via REST is noted in each method where applicable.
These method are now deprecated, and will be removed in the release after Bugzilla 5.0. The correct way of use these REST and RPC calls is noted in Bugzilla::WebService
DEPRECATED
Logging in, with a username and password, is required for many Bugzilla installations, in order to search for bugs, post new bugs, etc. This method logs in an user.
login
(string) - The user's login name.password
(string) - The user's password.restrict_login
(bool) Optional - If set to a true value,
the token returned by this method will only be valid from the IP address which called this method.On success,
a hash containing two items,
id
,
the numeric id of the user that was logged in,
and a token
which can be passed in the parameters as authentication in other calls.
The token can be sent along with any future requests to the webservice,
for the duration of the session,
i.e.
till User.logout is called.
The username does not exist, or the password is wrong.
The ability to login with this account has been disabled. A reason may be specified with the error.
The current password is correct, but the user is asked to change their password.
A login or password parameter was not provided.
remember
was removed in Bugzilla 5.0 as this method no longer creates a login cookie.restrict_login
was added in Bugzilla 5.0.token
was added in Bugzilla 4.4.3.DEPRECATED
Log out the user. Does nothing if there is no user logged in.
DEPRECATED
This method will verify whether a client's cookies or current login token is still valid or have expired. A valid username must be provided as well that matches.
login
The login name that matches the provided cookies or token.
token
(string) Persistent login token current being used for authentication (optional). Cookies passed by client will be used before the token if both provided.
Returns true/false depending on if the current cookies or token are valid for the provided username.
STABLE
Sends an email to the user, offering to create an account. The user will have to click on a URL in the email, and choose their password and real name.
This is the recommended way to create a Bugzilla account.
email
(string) - the email to send the offer to.An account with that email address already exists in Bugzilla.
This Bugzilla does not allow you to create accounts with the format of email address you specified. Account creation may be entirely disabled.
STABLE
Creates a user account directly in Bugzilla, password and all. Instead of this, you should use "offer_account_by_email" when possible, because that makes sure that the email address specified can actually receive an email. This function does not check that.
You must be logged in and have the editusers
privilege in order to call this function.
POST /rest/user
The params to include in the POST body as well as the returned data format, are the same as below.
email
(string) - The email address for the new user.full_name
(string) Optional - The user's full name.
Will be set to empty if not specified.password
(string) Optional - The password for the new user account,
in plain text.
It will be stripped of leading and trailing whitespace.
If blank or not specified,
the newly created account will exist in Bugzilla,
but will not be allowed to log in using DB authentication until a password is set either by the user (through resetting their password) or by the administrator.A hash containing one item,
id
,
the numeric id of the user that was created.
The same as "offer_account_by_email". If a password is specified, the function may also throw:
The password specified is too short. (Usually, this means the password is under three characters.)
EXPERIMENTAL
Updates user accounts in Bugzilla.
PUT /rest/user/<user_id_or_name>
The params to include in the PUT body as well as the returned data format,
are the same as below.
The ids
and names
params are overridden as they are pulled from the URL path.
ids
array
Contains ids of user to update.
names
array
Contains email/login of user to update.
full_name
string
The new name of the user.
email
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 login name / email.
(An error will be thrown if you try to update this field for multiple users at once.)
password
string
The password of the user.
email_enabled
boolean
A boolean value to enable/disable sending bug-related mail to the user.
login_denied_text
string
A text field that holds the reason for disabling a user from logging into bugzilla,
if empty then the user account is enabled otherwise it is disabled/closed.
groups
hash
These specify the groups that this user is directly a member of.
To set these,
you should pass a hash as the value.
The hash may contain the following fields:
add
An array of int
s or string
s.
The group ids or group names that the user should be added to.remove
An array of int
s or string
s.
The group ids or group names that the user should be removed from.set
An array of int
s or string
s.
An exact set of group ids and group names that the user should be a member of.
NOTE: This does not remove groups from the user where the person making the change does not have the bless privilege for.If you specify set
,
then add
and remove
will be ignored.
A group in both the add
and remove
list will be added.
Specifying a group that the user making the change does not have bless rights will generate an error.
bless_groups
hash
- This is the same as groups,
but affects what groups a user has direct membership to bless that group.
It takes the same inputs as groups.
A hash
with a single field "users".
This points to an array of hashes with the following fields:
id
int
The id of the user that was updated.
changes
hash
The changes that were actually done on this user.
The keys are the names of the fields that were changed,
and the values are a hash with two keys:
added
string
The values that were added to this field,
possibly a comma-and-space-separated list if multiple values were added.
removed
string
The values that were removed from this field,
possibly a comma-and-space-separated list if multiple values were removed.
You passed an invalid login name in the "names" array.
Logged-in users are not authorized to edit other users.
STABLE
Gets information about user accounts in Bugzilla.
To get information about a single user:
GET /rest/user/<user_id_or_name>
To search for users by name, group using URL params same as below:
GET /rest/user
The returned data format is the same as below.
Note: At least one of ids
,
names
,
or match
must be specified.
Note: Users will not be returned more than once, so even if a user is matched by more than one argument, only one user will be returned.
In addition to the parameters below, this method also accepts the standard include_fields and exclude_fields arguments.
ids
(array)An array of integers, representing user ids.
Logged-out users cannot pass this parameter to this function. If they try, they will get an error. Logged-in users will get an error if they specify the id of a user they cannot see.
names
(array)An array of login names (strings).
match
(array)An array of strings. This works just like "user matching" in Bugzilla itself. Users will be returned whose real name or login name contains any one of the specified strings. Users that you cannot see will not be included in the returned list.
Most installations have a limit on how many matches are returned for each string, which defaults to 1000 but can be changed by the Bugzilla administrator.
Logged-out users cannot use this argument, and an error will be thrown if they try. (This is to make it harder for spammers to harvest email addresses from Bugzilla, and also to enforce the user visibility restrictions that are implemented on some Bugzillas.)
limit
(int)Limit the number of users matched by the match
parameter.
If value is greater than the system limit,
the system limit will be used.
This parameter is only used when user matching using the match
parameter is being performed.
group_ids
(array)groups
(array)group_ids
is an array of numeric ids for groups that a user can be in.
groups
is an array of names of groups that a user can be in.
If these are specified,
they limit the return value to users who are in any of the groups specified.
include_disabled
(boolean)By default,
when using the match
parameter,
disabled users are excluded from the returned results unless their full username is identical to the match string.
Setting include_disabled
to true
will include disabled users in the returned results even if their username doesn't fully match the input string.
A hash containing one item,
users
,
that is an array of hashes.
Each hash describes a user,
and has the following items:
int
The unique integer ID that Bugzilla uses to represent this user.
Even if the user's login name changes,
this will not change.
string
The actual name of the user.
May be blank.
string
The email address of the user.
string
The login name of the user.
Note that in some situations this is different than their email.
boolean
A boolean value to indicate if the user can login into bugzilla.
boolean
A boolean value to indicate if bug-related mail will be sent to the user or not.
string
A text field that holds the reason for disabling a user from logging into bugzilla,
if empty then the user account is enabled.
Otherwise it is disabled/closed.
array
An array of group hashes the user is a member of.
If the currently logged in user is querying their own account or is a member of the 'editusers' group,
the array will contain all the groups that the user is a member of.
Otherwise,
the array will only contain groups that the logged in user can bless.
Each hash describes the group and contains the following items:
int
The group id
string
The name of the group
string
The description for the group
array
An array of hashes,
each of which represents a user's saved search and has the following keys:
int
An integer id uniquely identifying the saved search.
string
The name of the saved search.
string
The CGI parameters for the saved search.
array
An array of hashes,
each of which represents a user's saved report and has the following keys:
int
An integer id uniquely identifying the saved report.
string
The name of the saved report.
string
The CGI parameters for the saved report.
Note: If you are not logged in to Bugzilla when you call this function,
you will only be returned the id
,
name
,
and real_name
items.
If you are logged in and not in editusers group,
you will only be returned the id
,
name
,
real_name
,
email
,
can_login
,
and groups
items.
The groups returned are filtered based on your permission to bless each group.
The saved_searches
and saved_reports
items are only returned if you are querying your own account,
even if you are in the editusers group.
You passed an invalid login name in the "names" array or a bad group ID in the group_ids
argument.
The value used must be an integer greater than zero.
You are logged in, but you are not authorized to see one of the users you wanted to get information about by user id.
Logged-out users cannot use the "ids" or "match" arguments to this function.
You passed a group name in the groups
argument which either does not exist or you do not belong to it.
group_ids
and groups
were added in Bugzilla 4.0.include_disabled
was added in Bugzilla 4.0.
Default behavior for match
was changed to only return enabled accounts.groups
,
saved_searches
,
and saved_reports
were added in Bugzilla 4.4.