Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
faa0b904
Commit
faa0b904
authored
Oct 06, 2006
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 350232: Allow the Webservice interface to create User Accounts
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=Wurblzap, a=justdave
parent
ce0b20a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
0 deletions
+143
-0
Constants.pm
Bugzilla/WebService/Constants.pm
+6
-0
User.pm
Bugzilla/WebService/User.pm
+137
-0
No files found.
Bugzilla/WebService/Constants.pm
View file @
faa0b904
...
@@ -58,6 +58,12 @@ use constant WS_ERROR_CODE => {
...
@@ -58,6 +58,12 @@ use constant WS_ERROR_CODE => {
account_disabled
=>
301
,
account_disabled
=>
301
,
auth_invalid_email
=>
302
,
auth_invalid_email
=>
302
,
extern_id_conflict
=>
-
303
,
extern_id_conflict
=>
-
303
,
# User errors are 500-600.
account_exists
=>
500
,
illegal_email_address
=>
501
,
password_too_short
=>
502
,
password_too_long
=>
503
,
};
};
# These are the fallback defaults for errors not in ERROR_CODE.
# These are the fallback defaults for errors not in ERROR_CODE.
...
...
Bugzilla/WebService/User.pm
View file @
faa0b904
...
@@ -13,13 +13,25 @@
...
@@ -13,13 +13,25 @@
# The Original Code is the Bugzilla Bug Tracking System.
# The Original Code is the Bugzilla Bug Tracking System.
#
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
package
Bugzilla::WebService::
User
;
package
Bugzilla::WebService::
User
;
use
strict
;
use
strict
;
use
base
qw(Bugzilla::WebService)
;
use
base
qw(Bugzilla::WebService)
;
import
SOAP::
Data
qw(type)
;
use
Bugzilla
;
use
Bugzilla
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Error
;
use
Bugzilla::
User
;
use
Bugzilla::
Util
qw(trim)
;
use
Bugzilla::
Token
;
##############
# User Login #
##############
sub
login
{
sub
login
{
my
$self
=
shift
;
my
$self
=
shift
;
...
@@ -52,4 +64,129 @@ sub logout {
...
@@ -52,4 +64,129 @@ sub logout {
Bugzilla
->
logout
;
Bugzilla
->
logout
;
}
}
#################
# User Creation #
#################
sub
offer_account_by_email
{
my
$self
=
shift
;
my
(
$params
)
=
@_
;
my
$email
=
trim
(
$params
->
{
email
})
||
ThrowCodeError
(
'param_required'
,
{
param
=>
'email'
});
$email
=
Bugzilla::
User
->
check_login_name_for_creation
(
$email
);
# Create and send a token for this new account.
Bugzilla::Token::
issue_new_user_account_token
(
$email
);
return
undef
;
}
sub
create
{
my
$self
=
shift
;
my
(
$params
)
=
@_
;
Bugzilla
->
user
->
in_group
(
'editusers'
)
||
ThrowUserError
(
"auth_failure"
,
{
group
=>
"editusers"
,
action
=>
"add"
,
object
=>
"users"
});
my
$email
=
trim
(
$params
->
{
email
})
||
ThrowCodeError
(
'param_required'
,
{
param
=>
'email'
});
my
$realname
=
trim
(
$params
->
{
full_name
});
my
$password
=
trim
(
$params
->
{
password
})
||
'*'
;
my
$user
=
Bugzilla::
User
->
create
({
login_name
=>
$email
,
realname
=>
$realname
,
cryptpassword
=>
$password
});
return
{
user_id
=>
type
(
'int'
)
->
value
(
$user
->
id
)
};
}
1
;
1
;
__END__
=head1 NAME
Bugzilla::Webservice::User - The User Account and Login API
=head1 DESCRIPTION
This part of the Bugzilla API allows you to create User Accounts.
=head1 METHODS
See L<Bugzilla::WebService> for a description of what B<STABLE>, B<UNSTABLE>,
and B<EXPERIMENTAL> mean, and for more information about error codes.
=head2 Account Creation
=over
=item C<offer_account_by_email> B<EXPERIMENTAL>
Description: 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.
Params: C<email> - The email to send the offer to.
Returns: nothing
=over
=item 500 (Illegal Email Address)
This Bugzilla does not allow you to create accounts with the format of
email address you specified. Account creation may be entirely disabled.
=item 501 (Account Already Exists)
An account with that email address already exists in Bugzilla.
=back
=item C<create> B<EXPERIMENTAL>
Description: Creates a user account directly in Bugzilla, password and all.
Instead of this, you should use L</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.
Params: C<email> B<Required> - The email address for the new user.
C<full_name> - A string, the user's full name. Will be
set to empty if not specified.
C<password> - 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.
Returns: A hash containing one item, C<user_id>, the numeric id of
the user that was created.
Errors: The same as L</offer_account_by_email>. If a password
is specified, the function may also throw:
=over
=item 502 (Password Too Short)
The password specified is too short. (Usually, this means the
password is under three characters.)
=item 503 (Password Too Long)
The password specified is too long. (Usually, this means the
password is over ten characters.)
=back
=back
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment