diff --git a/internal/httpd/webadmin.go b/internal/httpd/webadmin.go index aed7e5b0..99a34a15 100644 --- a/internal/httpd/webadmin.go +++ b/internal/httpd/webadmin.go @@ -100,12 +100,9 @@ const ( templateMaintenance = "maintenance.html" templateMFA = "mfa.html" templateSetup = "adminsetup.html" - pageUsersTitle = "Users" pageAdminsTitle = "Admins" pageConnectionsTitle = "Connections" pageStatusTitle = "Status" - pageFoldersTitle = "Folders" - pageGroupsTitle = "Groups" pageEventRulesTitle = "Event rules" pageEventActionsTitle = "Event actions" pageRolesTitle = "Roles" @@ -1380,18 +1377,9 @@ func getFilePatternsFromPostField(r *http.Request) []sdk.PatternsFilter { for idx := range patternPaths { p := patternPaths[idx] - filters := "" - patternType := "" - patternPolicy := "" - if len(patterns) > idx { - filters = strings.ReplaceAll(patterns[idx], " ", "") - } - if len(patternTypes) > idx { - patternType = patternTypes[idx] - } - if len(patternPolicies) > idx { - patternPolicy = policies[idx] - } + filters := strings.ReplaceAll(patterns[idx], " ", "") + patternType := patternTypes[idx] + patternPolicy := policies[idx] if p != "" && filters != "" { if patternType == "allowed" { allowedPatterns[p] = append(allowedPatterns[p], strings.Split(filters, ",")...) @@ -2998,7 +2986,7 @@ func (s *httpdServer) handleGetWebUsers(w http.ResponseWriter, r *http.Request) s.renderBadRequestPage(w, r, errors.New("invalid token claims")) return } - data := s.getBasePageData(pageUsersTitle, webUsersPath, r) + data := s.getBasePageData(util.I18nUsersTitle, webUsersPath, r) renderAdminTemplate(w, templateUsers, data) } @@ -3487,7 +3475,7 @@ func (s *httpdServer) handleWebGetFolders(w http.ResponseWriter, r *http.Request } data := foldersPage{ - basePage: s.getBasePageData(pageFoldersTitle, webFoldersPath, r), + basePage: s.getBasePageData(util.I18nFoldersTitle, webFoldersPath, r), Folders: folders, } renderAdminTemplate(w, templateFolders, data) @@ -3529,7 +3517,7 @@ func getAllGroups(w http.ResponseWriter, r *http.Request) { func (s *httpdServer) handleWebGetGroups(w http.ResponseWriter, r *http.Request) { r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize) - data := s.getBasePageData(pageGroupsTitle, webGroupsPath, r) + data := s.getBasePageData(util.I18nGroupsTitle, webGroupsPath, r) renderAdminTemplate(w, templateGroups, data) } diff --git a/internal/util/i18n.go b/internal/util/i18n.go index a25eb54f..e4480fb6 100644 --- a/internal/util/i18n.go +++ b/internal/util/i18n.go @@ -29,6 +29,9 @@ const ( I18nShareAddTitle = "title.add_share" I18nShareUpdateTitle = "title.update_share" I18nProfileTitle = "title.profile" + I18nUsersTitle = "title.users" + I18nGroupsTitle = "title.groups" + I18nFoldersTitle = "title.folders" I18nChangePwdTitle = "title.change_password" I18n2FATitle = "title.two_factor_auth" I18nEditFileTitle = "title.edit_file" diff --git a/internal/vfs/httpfs.go b/internal/vfs/httpfs.go index dfe4ab22..04399b7a 100644 --- a/internal/vfs/httpfs.go +++ b/internal/vfs/httpfs.go @@ -164,7 +164,8 @@ func (c *HTTPFsConfig) validate() error { // ValidateAndEncryptCredentials validates the config and encrypts credentials if they are in plain text func (c *HTTPFsConfig) ValidateAndEncryptCredentials(additionalData string) error { - if err := c.validate(); err != nil { + err := c.validate() + if err != nil { var errI18n *util.I18nError errValidation := util.NewValidationError(fmt.Sprintf("could not validate HTTP fs config: %v", err)) if errors.As(err, &errI18n) {