зеркало из https://github.com/mozilla/pjs.git
Bug 304582: Move GenerateRandomPassword() out of globals.pl - Patch by Fr�d�ric Buclin <LpSolit@gmail.com> r=joel a=myk
This commit is contained in:
Родитель
7e6d859af6
Коммит
4ad6bb5d49
|
@ -150,7 +150,7 @@ sub CleanTokenTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub GenerateUniqueToken {
|
sub GenerateUniqueToken {
|
||||||
# Generates a unique random token. Uses &GenerateRandomPassword
|
# Generates a unique random token. Uses generate_random_password
|
||||||
# for the tokens themselves and checks uniqueness by searching for
|
# for the tokens themselves and checks uniqueness by searching for
|
||||||
# the token in the "tokens" table. Gives up if it can't come up
|
# the token in the "tokens" table. Gives up if it can't come up
|
||||||
# with a token after about one hundred tries.
|
# with a token after about one hundred tries.
|
||||||
|
@ -167,7 +167,7 @@ sub GenerateUniqueToken {
|
||||||
if ($tries > 100) {
|
if ($tries > 100) {
|
||||||
ThrowCodeError("token_generation_error");
|
ThrowCodeError("token_generation_error");
|
||||||
}
|
}
|
||||||
$token = &::GenerateRandomPassword();
|
$token = generate_random_password();
|
||||||
$sth->execute($token);
|
$sth->execute($token);
|
||||||
$duplicate = $sth->fetchrow_array;
|
$duplicate = $sth->fetchrow_array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1153,7 +1153,7 @@ sub insert_new_user {
|
||||||
$disabledtext ||= '';
|
$disabledtext ||= '';
|
||||||
|
|
||||||
# If not specified, generate a new random password for the user.
|
# If not specified, generate a new random password for the user.
|
||||||
$password ||= &::GenerateRandomPassword();
|
$password ||= generate_random_password();
|
||||||
my $cryptpassword = bz_crypt($password);
|
my $cryptpassword = bz_crypt($password);
|
||||||
|
|
||||||
# XXX - These should be moved into is_available_username or validate_email_syntax
|
# XXX - These should be moved into is_available_username or validate_email_syntax
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
# Bradley Baetz <bbaetz@student.usyd.edu.au>
|
# Bradley Baetz <bbaetz@student.usyd.edu.au>
|
||||||
# Christopher Aillon <christopher@aillon.com>
|
# Christopher Aillon <christopher@aillon.com>
|
||||||
# Max Kanat-Alexander <mkanat@bugzilla.org>
|
# Max Kanat-Alexander <mkanat@bugzilla.org>
|
||||||
|
# Frédéric Buclin <LpSolit@gmail.com>
|
||||||
|
|
||||||
package Bugzilla::Util;
|
package Bugzilla::Util;
|
||||||
|
|
||||||
|
@ -40,7 +41,8 @@ use base qw(Exporter);
|
||||||
perform_substs
|
perform_substs
|
||||||
format_time format_time_decimal validate_date
|
format_time format_time_decimal validate_date
|
||||||
file_mod_time is_7bit_clean
|
file_mod_time is_7bit_clean
|
||||||
bz_crypt validate_email_syntax);
|
bz_crypt generate_random_password
|
||||||
|
validate_email_syntax);
|
||||||
|
|
||||||
use Bugzilla::Config;
|
use Bugzilla::Config;
|
||||||
use Bugzilla::Constants;
|
use Bugzilla::Constants;
|
||||||
|
@ -356,6 +358,11 @@ sub bz_crypt {
|
||||||
return $cryptedpassword;
|
return $cryptedpassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub generate_random_password {
|
||||||
|
my $size = shift || 10; # default to 10 chars if nothing specified
|
||||||
|
return join("", map{ ('0'..'9','a'..'z','A'..'Z')[rand 62] } (1..$size));
|
||||||
|
}
|
||||||
|
|
||||||
sub validate_email_syntax {
|
sub validate_email_syntax {
|
||||||
my ($addr) = @_;
|
my ($addr) = @_;
|
||||||
my $match = Param('emailregexp');
|
my $match = Param('emailregexp');
|
||||||
|
@ -435,6 +442,7 @@ Bugzilla::Util - Generic utility functions for bugzilla
|
||||||
|
|
||||||
# Cryptographic Functions
|
# Cryptographic Functions
|
||||||
$crypted_password = bz_crypt($password);
|
$crypted_password = bz_crypt($password);
|
||||||
|
$new_password = generate_random_password($password_length);
|
||||||
|
|
||||||
# Validation Functions
|
# Validation Functions
|
||||||
validate_email_syntax($email);
|
validate_email_syntax($email);
|
||||||
|
@ -689,6 +697,12 @@ characters of the password to anyone who views the encrypted version.
|
||||||
|
|
||||||
=end undocumented
|
=end undocumented
|
||||||
|
|
||||||
|
=item C<generate_random_password($password_length)>
|
||||||
|
|
||||||
|
Returns an alphanumeric string with the specified length
|
||||||
|
(10 characters by default). Use this function to generate passwords
|
||||||
|
and tokens.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head2 Validation
|
=head2 Validation
|
||||||
|
|
|
@ -341,11 +341,6 @@ sub GetVersionTable {
|
||||||
$::VersionTableLoaded = 1;
|
$::VersionTableLoaded = 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));
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# This function checks if there are any entry groups defined.
|
# This function checks if there are any entry groups defined.
|
||||||
# If called with no arguments, it identifies
|
# If called with no arguments, it identifies
|
||||||
|
|
Загрузка…
Ссылка в новой задаче