Skip to content

Commit

Permalink
allow updating settings without a username field if DisableLocalAuth …
Browse files Browse the repository at this point in the history
…is set
  • Loading branch information
thefinn93 committed Jul 18, 2024
1 parent 5a4d85c commit 229360e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/ui/form/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"strconv"

"miniflux.app/v2/internal/config"
"miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/model"
)
Expand Down Expand Up @@ -40,7 +41,9 @@ type SettingsForm struct {

// Merge updates the fields of the given user.
func (s *SettingsForm) Merge(user *model.User) *model.User {
user.Username = s.Username
if !config.Opts.DisableLocalAuth() {
user.Username = s.Username
}
user.Theme = s.Theme
user.Language = s.Language
user.Timezone = s.Timezone
Expand Down Expand Up @@ -71,7 +74,7 @@ func (s *SettingsForm) Merge(user *model.User) *model.User {

// Validate makes sure the form values are valid.
func (s *SettingsForm) Validate() *locale.LocalizedError {
if s.Username == "" || s.Theme == "" || s.Language == "" || s.Timezone == "" || s.EntryDirection == "" || s.DisplayMode == "" || s.DefaultHomePage == "" {
if (s.Username == "" && !config.Opts.DisableLocalAuth()) || s.Theme == "" || s.Language == "" || s.Timezone == "" || s.EntryDirection == "" || s.DisplayMode == "" || s.DefaultHomePage == "" {
return locale.NewLocalizedError("error.settings_mandatory_fields")
}

Expand Down

0 comments on commit 229360e

Please sign in to comment.