Skip to content

Commit e7b24a6

Browse files
nextgensdregad
authored andcommittedDec 13, 2012
Remove the seed parameter of auth_generate_* functions
The following functions shouldn't take a seed; random is random! - auth_generate_random_password() - auth_generate_unique_cookie_string Signed-off-by: Damien Regad <damien.regad@merckgroup.com>
1 parent c7e261e commit e7b24a6

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed
 

‎core/authentication_api.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ function auth_process_plain_password( $p_password, $p_salt = null, $p_method = n
477477
* @return string 16 character random password
478478
* @access public
479479
*/
480-
function auth_generate_random_password( $p_email ) {
480+
function auth_generate_random_password() {
481481
# !TODO: create memorable passwords?
482482
return crypto_generate_uri_safe_nonce( 16 );
483483
}

‎core/user_api.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,7 @@ function user_create( $p_username, $p_password, $p_email = '',
477477
user_ensure_realname_unique( $p_username, $p_realname );
478478
email_ensure_valid( $p_email );
479479

480-
$t_seed = $p_email . $p_username;
481-
$t_cookie_string = auth_generate_unique_cookie_string( $t_seed );
480+
$t_cookie_string = auth_generate_unique_cookie_string();
482481
$t_user_table = db_get_table( 'user' );
483482

484483
$query = "INSERT INTO $t_user_table
@@ -540,10 +539,8 @@ function user_signup( $p_username, $p_email = null ) {
540539

541540
$p_email = trim( $p_email );
542541

543-
$t_seed = $p_email . $p_username;
544-
545542
# Create random password
546-
$t_password = auth_generate_random_password( $t_seed );
543+
$t_password = auth_generate_random_password();
547544

548545
return user_create( $p_username, $t_password, $p_email );
549546
}
@@ -1393,8 +1390,7 @@ function user_set_password( $p_user_id, $p_password, $p_allow_protected = false
13931390

13941391
# When the password is changed, invalidate the cookie to expire sessions that
13951392
# may be active on all browsers.
1396-
$t_seed = $t_email . $t_username;
1397-
$c_cookie_string = auth_generate_unique_cookie_string( $t_seed );
1393+
$c_cookie_string = auth_generate_unique_cookie_string();
13981394

13991395
$c_user_id = db_prepare_int( $p_user_id );
14001396
$c_password = auth_process_plain_password( $p_password );
@@ -1457,8 +1453,7 @@ function user_reset_password( $p_user_id, $p_send_email = true ) {
14571453
if(( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
14581454

14591455
# Create random password
1460-
$t_email = user_get_field( $p_user_id, 'email' );
1461-
$t_password = auth_generate_random_password( $t_email );
1456+
$t_password = auth_generate_random_password();
14621457
$t_password2 = auth_process_plain_password( $t_password );
14631458

14641459
user_set_field( $p_user_id, 'password', $t_password2 );

‎manage_user_create.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@
9494
if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
9595
# Check code will be sent to the user directly via email. Dummy password set to random
9696
# Create random password
97-
$t_seed = $f_email . $f_username;
98-
$f_password = auth_generate_random_password( $t_seed );
97+
$f_password = auth_generate_random_password();
9998
} else {
10099
# Password won't to be sent by email. It entered by the admin
101100
# Now, if the password is empty, confirm that that is what we wanted

0 commit comments

Comments
 (0)
Please sign in to comment.