From e65cfe5ce1c7de66173bbd901a261120c5013254 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 7 Jan 2026 11:37:48 -0700 Subject: [PATCH] Update descriptions for generate_password and for password_lowercase setting --- core/users/app_config.php | 2 +- resources/functions.php | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/users/app_config.php b/core/users/app_config.php index be44a1202e..500d2190a8 100644 --- a/core/users/app_config.php +++ b/core/users/app_config.php @@ -138,7 +138,7 @@ $apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean"; $apps[$x]['default_settings'][$y]['default_setting_value'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; - $apps[$x]['default_settings'][$y]['default_setting_description'] = "Set whether to require at least one lowecase letter in user passwords."; + $apps[$x]['default_settings'][$y]['default_setting_description'] = "Set whether to require at least one lowercase letter in user passwords."; $y++; $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "973b6773-dac0-4041-844e-71c48fc9542c"; $apps[$x]['default_settings'][$y]['default_setting_category'] = "users"; diff --git a/resources/functions.php b/resources/functions.php index edf41c6022..18c2e82524 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1303,9 +1303,10 @@ function tail(string $file, int $num_to_get = 10): string { /** * Generates a random password of specified length and strength. * - * @param int $length The desired length of the password. Defaults to default settings if not provided or zero. - * @param int $strength The desired strength level of the password. Defaults to default settings if not provided or - * zero. + * @param int $length The desired length of the password. Defaults to 0 if not provided. + * @param int $strength The desired strength level of the password. + * This defaults to 3 if not provided. The higher level includes the previous levels. + * If the password_strength was set to 3, this would include numeric, lowercase, and uppercase letters. * - Level 1: Numeric * - Level 2: Lowercase letters * - Level 3: Uppercase letters @@ -1314,16 +1315,13 @@ function tail(string $file, int $num_to_get = 10): string { * @return string The generated password. * @throws \Random\RandomException */ -function generate_password(int $length = 0, int $strength = 0): string { +function generate_password(int $length = 0, int $strength = 3): string { //define the global variables global $settings; $password = ''; $chars = ''; - if ($length === 0 && $strength === 0) { //set length and strenth if specified in default settings and strength isn't numeric-only - $length = (is_numeric($settings->get('users', 'password_length'))) ? $settings->get('users', 'password_length') : 20; - $strength = (is_numeric($settings->get('users', 'password_strength'))) ? $settings->get('users', 'password_strength') : 4; - } + if ($strength >= 1) { $chars .= "0123456789"; }