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
e564c92b
Commit
e564c92b
authored
Feb 09, 2005
by
travis%sedsystems.ca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 280994 : Move ValidateNewUser out of globals.pl
Patch by Max Kanat-Alexander <mkanat@kerio.com> r=vladd a=justdave
parent
f8aeecaf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
40 deletions
+55
-40
LDAP.pm
Bugzilla/Auth/Verify/LDAP.pm
+1
-1
User.pm
Bugzilla/User.pm
+48
-1
createaccount.cgi
createaccount.cgi
+2
-2
editusers.cgi
editusers.cgi
+1
-1
globals.pl
globals.pl
+0
-33
token.cgi
token.cgi
+1
-1
userprefs.cgi
userprefs.cgi
+2
-1
No files found.
Bugzilla/Auth/Verify/LDAP.pm
View file @
e564c92b
...
...
@@ -33,7 +33,7 @@ use strict;
use
Bugzilla::
Config
;
use
Bugzilla::
Constants
;
use
Bugzilla::
User
qw(insert_new_user)
;
use
Bugzilla::
User
;
use
Net::
LDAP
;
...
...
Bugzilla/User.pm
View file @
e564c92b
...
...
@@ -40,7 +40,7 @@ use Bugzilla::Constants;
use
Bugzilla::
Auth
;
use
base
qw(Exporter)
;
@
Bugzilla::User::
EXPORT
_OK
=
qw(insert_new_user
)
;
@
Bugzilla::User::
EXPORT
=
qw(insert_new_user is_available_username
)
;
################################################################################
# Functions
...
...
@@ -958,6 +958,40 @@ sub insert_new_user ($$) {
return
$password
;
}
sub
is_available_username
($;$) {
my
(
$username
,
$old_username
)
=
@_
;
if
(
&::
DBname_to_id
(
$username
)
!=
0
)
{
return
0
;
}
my
$dbh
=
Bugzilla
->
dbh
;
# $username is safe because it is only used in SELECT placeholders.
trick_taint
(
$username
);
# Reject if the new login is part of an email change which is
# still in progress
#
# substring/locate stuff: bug 165221; this used to use regexes, but that
# was unsafe and required weird escaping; using substring to pull out
# the new/old email addresses and locate() to find the delimeter (':')
# is cleaner/safer
my
$sth
=
$dbh
->
prepare
(
"SELECT eventdata FROM tokens WHERE tokentype = 'emailold'
AND SUBSTRING(eventdata, 1, (LOCATE(':', eventdata) - 1)) = ?
OR SUBSTRING(eventdata, (LOCATE(':', eventdata) + 1)) = ?"
);
$sth
->
execute
(
$username
,
$username
);
if
(
my
(
$eventdata
)
=
$sth
->
fetchrow_array
())
{
# Allow thru owner of token
if
(
$old_username
&&
(
$eventdata
eq
"$old_username:$username"
))
{
return
1
;
}
return
0
;
}
return
1
;
}
1
;
__END__
...
...
@@ -1183,6 +1217,19 @@ Params: $username (scalar, string) - The login name for the new user.
Returns: The password that we randomly generated for this user, in plain text.
=item C<is_available_username>
Returns a boolean indicating whether or not the supplied username is
already taken in Bugzilla.
Params: $username (scalar, string) - The full login name of the username
that you are checking.
$old_username (scalar, string) - If you are checking an email-change
token, insert the "old" username that the user is changing from,
here. Then, as long as it's the right user for that token, he
can change his username to $username. (That is, this function
will return a boolean true value).
=back
=head1 SEE ALSO
...
...
createaccount.cgi
View file @
e564c92b
...
...
@@ -30,7 +30,7 @@ use lib qw(.);
require
"CGI.pl"
;
use
Bugzilla::
User
qw(insert_new_user)
;
use
Bugzilla::
User
;
# Shut up misguided -w warnings about "used only once":
use
vars
qw(
...
...
@@ -61,7 +61,7 @@ if (defined($login)) {
CheckEmailSyntax
(
$login
);
$vars
->
{
'login'
}
=
$login
;
if
(
!
ValidateNewUser
(
$login
))
{
if
(
!
is_available_username
(
$login
))
{
# Account already exists
$template
->
process
(
"account/exists.html.tmpl"
,
$vars
)
||
ThrowTemplateError
(
$template
->
error
());
...
...
editusers.cgi
View file @
e564c92b
...
...
@@ -434,7 +434,7 @@ if ($action eq 'new') {
PutTrailer
(
$localtrailer
);
exit
;
}
if
(
!
ValidateNewUser
(
$user
))
{
if
(
!
is_available_username
(
$user
))
{
print
"The user '$user' does already exist. Please press\n"
;
print
"<b>Back</b> and try again.\n"
;
PutTrailer
(
$localtrailer
);
...
...
globals.pl
View file @
e564c92b
...
...
@@ -375,39 +375,6 @@ sub GetVersionTable {
$::VersionTableLoaded
=
1
;
}
# Validates a given username as a new username
# returns 1 if valid, 0 if invalid
sub
ValidateNewUser
{
my
(
$username
,
$old_username
)
=
@_
;
if
(
DBname_to_id
(
$username
)
!=
0
)
{
return
0
;
}
my
$sqluname
=
SqlQuote
(
$username
);
# Reject if the new login is part of an email change which is
# still in progress
#
# substring/locate stuff: bug 165221; this used to use regexes, but that
# was unsafe and required weird escaping; using substring to pull out
# the new/old email addresses and locate() to find the delimeter (':')
# is cleaner/safer
SendSQL
(
"SELECT eventdata FROM tokens WHERE tokentype = 'emailold'
AND SUBSTRING(eventdata, 1, (LOCATE(':', eventdata) - 1)) = $sqluname
OR SUBSTRING(eventdata, (LOCATE(':', eventdata) + 1)) = $sqluname"
);
if
(
my
(
$eventdata
)
=
FetchSQLData
())
{
# Allow thru owner of token
if
(
$old_username
&&
(
$eventdata
eq
"$old_username:$username"
))
{
return
1
;
}
return
0
;
}
return
1
;
}
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
));
...
...
token.cgi
View file @
e564c92b
...
...
@@ -243,7 +243,7 @@ sub changeEmail {
}
# The new email address should be available as this was
# confirmed initially so cancel token if it is not still available
if
(
!
ValidateNewUser
(
$new_email
,
$old_email
))
{
if
(
!
is_available_username
(
$new_email
,
$old_email
))
{
$vars
->
{
'email'
}
=
$new_email
;
# Needed for Bugzilla::Token::Cancel's mail
Bugzilla::Token::
Cancel
(
$::token
,
"account_exists"
);
ThrowUserError
(
"account_exists"
,
{
email
=>
$new_email
}
);
...
...
userprefs.cgi
View file @
e564c92b
...
...
@@ -29,6 +29,7 @@ use Bugzilla;
use
Bugzilla::
Constants
;
use
Bugzilla::
Search
;
use
Bugzilla::
Auth
;
use
Bugzilla::
User
;
require
"CGI.pl"
;
...
...
@@ -122,7 +123,7 @@ sub SaveAccount {
# Before changing an email address, confirm one does not exist.
CheckEmailSyntax
(
$new_login_name
);
trick_taint
(
$new_login_name
);
ValidateNewUser
(
$new_login_name
)
is_available_username
(
$new_login_name
)
||
ThrowUserError
(
"account_exists"
,
{
email
=>
$new_login_name
});
Bugzilla::Token::
IssueEmailChangeToken
(
$userid
,
$old_login_name
,
...
...
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