Skip to content

Improve default user creation logic at startup #1701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Pew-X
Copy link

@Pew-X Pew-X commented Apr 20, 2025

This commit refactors the default user creation logic in server/main.go to improve clarity and robustness.

Previously, the default user was only added if a password was provided in the configuration. This change ensures the default user (specified by config.Config.Username) is always added to the auth.UserStore at startup. The user's password is now set conditionally .

This addresses the TODO comment about handling user addition better, and I attempted to decouple the user's existence from its password configuration.

Testing:
The relevant tests for the underlying authentication functions (TestUsersAddAndGet, TestUserSetPassword, TestNewSession) in internal/auth/session_test.go were run and passed successfully.

Important Note: The test file internal/auth/session_test.go had pre-existing compile errors unrelated to this change. Parts of the file had to be temporarily commented out to execute the relevant tests. Please do correct me if I am wrong.

@CLAassistant
Copy link

CLAassistant commented Apr 20, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants