mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-05 23:44:22 +00:00
Add theme to user preferences
This commit is contained in:
@@ -16,6 +16,7 @@ type UpdateProfileRequest struct {
|
||||
Email string `json:"email"`
|
||||
CurrentPassword string `json:"currentPassword"`
|
||||
NewPassword string `json:"newPassword"`
|
||||
Theme string `json:"theme"`
|
||||
}
|
||||
|
||||
// DeleteAccountRequest represents a user account deletion request
|
||||
@@ -149,6 +150,19 @@ func (h *Handler) UpdateProfile() http.HandlerFunc {
|
||||
updates["displayNameChanged"] = true
|
||||
}
|
||||
|
||||
// Update theme if provided
|
||||
if req.Theme != "" {
|
||||
// Validate theme value, fallback to "dark" if invalid
|
||||
if req.Theme != "light" && req.Theme != "dark" {
|
||||
log.Debug("invalid theme value, falling back to dark",
|
||||
"theme", req.Theme,
|
||||
)
|
||||
req.Theme = "dark"
|
||||
}
|
||||
user.Theme = req.Theme
|
||||
updates["themeChanged"] = true
|
||||
}
|
||||
|
||||
// Update user in database
|
||||
if err := h.DB.UpdateUser(user); err != nil {
|
||||
log.Error("failed to update user in database",
|
||||
|
||||
Reference in New Issue
Block a user