jocxfin / pwgen

Simple self hosted password generator
GNU Affero General Public License v3.0
53 stars 3 forks source link

[BUG] Env variables are not respected on initial generation #69

Closed jocxfin closed 6 months ago

jocxfin commented 6 months ago

Describe the bug
The application does not adhere to the specified default settings for password length and passphrase separator type upon initial page load. Despite setting the default password length to 16 characters and the passphrase separator to a space, the application initially generates passwords with only 12 characters and uses a dash as the default separator between passphrase words.

To Reproduce
Steps to reproduce the behavior:

  1. Set up the application with specific environment variables, including PW_LENGTH=16 and PP_SEPARATOR_TYPE=space.
  2. Launch the Docker container and navigate to the web page to observe the initial password/passphrase generation.
  3. Notice the generated passwords contain only 12 characters, contrary to the specified 16.
  4. Click on the "Generate" button to produce new passwords/passphrases.
  5. Observe that now generated passwords meet the 16-character length requirement, but the initial passphrase still uses a dash as the separator instead of a space.

Expected behavior
The application should generate passwords and passphrases adhering to the specified environment variables upon initial page load. This includes generating passwords with a length of 16 characters and using a space as the default separator between passphrase words, as configured.

Screenshots
Not applicable.

Additional context
The issue seems to be related to the application's handling of default values and the transition between these defaults and user-specified configurations. Initial investigations suggest there might be an overlap or a precedence issue where default settings are applied before user-configured environment variables take effect.

Source: https://www.reddit.com/r/selfhosted/comments/1btg3yt/comment/kxzb0uw/