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
b7e1208d
Commit
b7e1208d
authored
Feb 01, 2005
by
travis%sedsystems.ca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 280124 : Move InsertNewUser to Bugzilla::User
Patch by Max Kanat-Alexander <mkanat@kerio.com> r=vladd a=justdave
parent
955aba68
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
26 deletions
+55
-26
LDAP.pm
Bugzilla/Auth/Verify/LDAP.pm
+2
-1
User.pm
Bugzilla/User.pm
+50
-0
createaccount.cgi
createaccount.cgi
+3
-1
globals.pl
globals.pl
+0
-24
No files found.
Bugzilla/Auth/Verify/LDAP.pm
View file @
b7e1208d
...
...
@@ -33,6 +33,7 @@ use strict;
use
Bugzilla::
Config
;
use
Bugzilla::
Constants
;
use
Bugzilla::
User
qw(insert_new_user)
;
use
Net::
LDAP
;
...
...
@@ -149,7 +150,7 @@ sub authenticate {
if
(
$userRealName
eq
""
)
{
$userRealName
=
$user_entry
->
get_value
(
"cn"
);
}
&::
InsertNewU
ser
(
$username
,
$userRealName
);
insert_new_u
ser
(
$username
,
$userRealName
);
(
$userid
,
$disabledtext
)
=
$dbh
->
selectrow_array
(
$sth
,
undef
,
...
...
Bugzilla/User.pm
View file @
b7e1208d
...
...
@@ -37,6 +37,10 @@ use Bugzilla::Config;
use
Bugzilla::
Error
;
use
Bugzilla::
Util
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Auth
;
use
Exporter
qw(import)
;
@
Bugzilla::User::
EXPORT_OK
=
qw(insert_new_user)
;
################################################################################
# Functions
...
...
@@ -929,6 +933,31 @@ sub get_userlist {
return
$self
->
{
'userlist'
};
}
sub
insert_new_user
($$)
{
my
(
$username
,
$realname
)
=
(
@_
);
my
$dbh
=
Bugzilla
->
dbh
;
# Generate a new random password for the user.
my
$password
=
&::
GenerateRandomPassword
();
my
$cryptpassword
=
bz_crypt
(
$password
);
# XXX - These should be moved into ValidateNewUser or CheckEmailSyntax
# At the least, they shouldn't be here. They're safe for now, though.
trick_taint
(
$username
);
trick_taint
(
$realname
);
# Insert the new user record into the database.
$dbh
->
do
(
"INSERT INTO profiles
(login_name, realname, cryptpassword, emailflags)
VALUES (?, ?, ?, ?)"
,
undef
,
(
$username
,
$realname
,
$cryptpassword
,
DEFAULT_EMAIL_SETTINGS
));
# Return the password to the calling code so it can be included
# in an email sent to the user.
return
$password
;
}
1
;
__END__
...
...
@@ -943,6 +972,9 @@ Bugzilla::User - Object for a Bugzilla user
my $user = new Bugzilla::User($id);
# Class Functions
$random_password = insert_new_user($username, $realname);
=head1 DESCRIPTION
This package handles Bugzilla users. Data obtained from here is read-only;
...
...
@@ -1135,6 +1167,24 @@ value.
=back
=head1 CLASS FUNCTIONS
=over4
These are functions that are not called on a User object, but instead are
called "statically," just like a normal procedural function.
=item C<insert_new_user>
Creates a new user in the database with a random password.
Params: $username (scalar, string) - The login name for the new user.
$realname (scalar, string) - The full name for the new user.
Returns: The password that we randomly generated for this user, in plain text.
=back
=head1 SEE ALSO
L<Bugzilla|Bugzilla>
createaccount.cgi
View file @
b7e1208d
...
...
@@ -30,6 +30,8 @@ use lib qw(.);
require
"CGI.pl"
;
use
Bugzilla::
User
qw(insert_new_user)
;
# Shut up misguided -w warnings about "used only once":
use
vars
qw(
$template
...
...
@@ -74,7 +76,7 @@ if (defined($login)) {
}
# Create account
my
$password
=
InsertNewU
ser
(
$login
,
$realname
);
my
$password
=
insert_new_u
ser
(
$login
,
$realname
);
MailPassword
(
$login
,
$password
);
$template
->
process
(
"account/created.html.tmpl"
,
$vars
)
...
...
globals.pl
View file @
b7e1208d
...
...
@@ -410,30 +410,6 @@ sub ValidateNewUser {
return
1
;
}
sub
InsertNewUser
{
my
(
$username
,
$realname
)
=
(
@_
);
# Generate a new random password for the user.
my
$password
=
GenerateRandomPassword
();
my
$cryptpassword
=
bz_crypt
(
$password
);
my
$defaultflagstring
=
SqlQuote
(
Bugzilla::Constants::
DEFAULT_EMAIL_SETTINGS
);
# Insert the new user record into the database.
$username
=
SqlQuote
(
$username
);
$realname
=
SqlQuote
(
$realname
);
$cryptpassword
=
SqlQuote
(
$cryptpassword
);
PushGlobalSQLState
();
SendSQL
(
"INSERT INTO profiles (login_name, realname, cryptpassword, emailflags)
VALUES ($username, $realname, $cryptpassword, $defaultflagstring)"
);
PopGlobalSQLState
();
# Return the password to the calling code so it can be included
# in an email sent to the user.
return
$password
;
}
sub
GenerateRandomPassword
{
my
$size
=
(
shift
or
10
);
# default to 10 chars if nothing specified
return
join
(
""
,
map
{
(
'0'
..
'9'
,
'a'
..
'z'
,
'A'
..
'Z'
)[
rand
62
]
}
(
1
..
$size
));
...
...
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