Skip to content

Comments

Improve default user creation logic at startup#1701

Closed
Pew-X wants to merge 1 commit intodicedb:masterfrom
Pew-X:master
Closed

Improve default user creation logic at startup#1701
Pew-X wants to merge 1 commit intodicedb:masterfrom
Pew-X:master

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.

@arpitbbhayani arpitbbhayani deleted the branch dicedb:master February 9, 2026 19:02
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.

3 participants