fix: default username to 'admin' if password is set but username is empty (#374)

Fixed an issue where hitting save with an empty username would fail
silently. This led users to think their changes were saved when they
actually weren't. Now it automatically defaults to "admin" if you set a
password but leave the username blank, making the save process reliable.

Cheers,

Your swiss librarian ;)
This commit is contained in:
bischoffjeremy
2025-12-30 09:32:33 +00:00
committed by GitHub
parent 74e657e955
commit dbe46e8e61
+8
View File
@@ -50,6 +50,7 @@ def _on_save_security(values: Dict[str, Any]) -> Dict[str, Any]:
- If new password is provided, validate confirmation and hash it
- If password fields are empty, preserve existing hash
- Never store raw passwords
- Ensure username is present if password is set
Returns:
Dict with processed values to save and any validation errors.
@@ -63,6 +64,13 @@ def _on_save_security(values: Dict[str, Any]) -> Dict[str, Any]:
# If password is provided, validate and hash it
if password:
if not values.get("BUILTIN_USERNAME"):
return {
"error": True,
"message": "Username cannot be empty",
"values": values
}
if password != password_confirm:
return {
"error": True,