mirror of
https://github.com/calibrain/shelfmark.git
synced 2026-09-24 21:00:31 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user