From ed828458ab4f8d334127ca66b3926631ed292904 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sat, 25 Nov 2023 18:11:10 +0100 Subject: [PATCH] WebUI add title to all pages Signed-off-by: Nicola Murino --- internal/httpd/web.go | 39 +++++++++++---------- internal/httpd/webadmin.go | 6 ++-- internal/httpd/webclient.go | 6 ++-- templates/common/forgot-password.html | 2 +- templates/common/reset-password.html | 2 +- templates/webadmin/twofactor-recovery.html | 2 +- templates/webadmin/twofactor.html | 2 +- templates/webclient/forgot-password.html | 2 +- templates/webclient/reset-password.html | 2 +- templates/webclient/twofactor-recovery.html | 2 +- templates/webclient/twofactor.html | 2 +- 11 files changed, 37 insertions(+), 30 deletions(-) diff --git a/internal/httpd/web.go b/internal/httpd/web.go index e64f867062b8862236db36dc1c1ca09ae157a19a..ccb99b22503b84302c645a51342163e33dc1ea5f 100644 --- a/internal/httpd/web.go +++ b/internal/httpd/web.go @@ -19,24 +19,26 @@ import ( ) const ( - pageMFATitle = "Two-factor authentication" - page400Title = "Bad request" - page403Title = "Forbidden" - page404Title = "Not found" - page404Body = "The page you are looking for does not exist." - page500Title = "Internal Server Error" - page500Body = "The server is unable to fulfill your request." - webDateTimeFormat = "2006-01-02 15:04:05" // YYYY-MM-DD HH:MM:SS - redactedSecret = "[**redacted**]" - csrfFormToken = "_form_token" - csrfHeaderToken = "X-CSRF-TOKEN" - templateCommonDir = "common" - templateTwoFactor = "twofactor.html" - templateTwoFactorRecovery = "twofactor-recovery.html" - templateForgotPassword = "forgot-password.html" - templateResetPassword = "reset-password.html" - templateCommonCSS = "sftpgo.css" - templateCommonBase = "base.html" + pageMFATitle = "Two-factor authentication" + page400Title = "Bad request" + page403Title = "Forbidden" + page404Title = "Not found" + page404Body = "The page you are looking for does not exist." + page500Title = "Internal Server Error" + page500Body = "The server is unable to fulfill your request." + pageTwoFactorTitle = "Two-Factor authentication" + pageTwoFactorRecoveryTitle = "Two-Factor recovery" + webDateTimeFormat = "2006-01-02 15:04:05" // YYYY-MM-DD HH:MM:SS + redactedSecret = "[**redacted**]" + csrfFormToken = "_form_token" + csrfHeaderToken = "X-CSRF-TOKEN" + templateCommonDir = "common" + templateTwoFactor = "twofactor.html" + templateTwoFactorRecovery = "twofactor-recovery.html" + templateForgotPassword = "forgot-password.html" + templateResetPassword = "reset-password.html" + templateCommonCSS = "sftpgo.css" + templateCommonBase = "base.html" ) type loginPage struct { @@ -62,6 +64,7 @@ type twoFactorPage struct { CSPNonce string StaticURL string RecoveryURL string + Title string Branding UIBranding } diff --git a/internal/httpd/webadmin.go b/internal/httpd/webadmin.go index 8dc6353fdb06805591a969636140f84eccb282ac..971fdddc361718e69dfc2da38edec900e7545cf6 100644 --- a/internal/httpd/webadmin.go +++ b/internal/httpd/webadmin.go @@ -120,8 +120,8 @@ const ( pageIPListsTitle = "IP Lists" pageEventsTitle = "Logs" pageConfigsTitle = "Configurations" - pageForgotPwdTitle = "SFTPGo Admin - Forgot password" - pageResetPwdTitle = "SFTPGo Admin - Reset password" + pageForgotPwdTitle = "Forgot password" + pageResetPwdTitle = "Reset password" pageSetupTitle = "Create first admin user" defaultQueryLimit = 1000 inversePatternType = "inverse" @@ -828,6 +828,7 @@ func (s *httpdServer) renderResetPwdPage(w http.ResponseWriter, r *http.Request, func (s *httpdServer) renderTwoFactorPage(w http.ResponseWriter, r *http.Request, error, ip string) { data := twoFactorPage{ + Title: pageTwoFactorTitle, CurrentURL: webAdminTwoFactorPath, Version: version.Get().Version, Error: error, @@ -842,6 +843,7 @@ func (s *httpdServer) renderTwoFactorPage(w http.ResponseWriter, r *http.Request func (s *httpdServer) renderTwoFactorRecoveryPage(w http.ResponseWriter, r *http.Request, error, ip string) { data := twoFactorPage{ + Title: pageTwoFactorRecoveryTitle, CurrentURL: webAdminTwoFactorRecoveryPath, Version: version.Get().Version, Error: error, diff --git a/internal/httpd/webclient.go b/internal/httpd/webclient.go index 53c94c9a2648eba34b87ca3bf48c10d21a495876..dd02be5ef80f026534f1004b617704ac275591fc 100644 --- a/internal/httpd/webclient.go +++ b/internal/httpd/webclient.go @@ -71,8 +71,8 @@ const ( pageClientChangePwdTitle = "Change password" pageClient2FATitle = "Two-factor auth" pageClientEditFileTitle = "Edit file" - pageClientForgotPwdTitle = "SFTPGo WebClient - Forgot password" - pageClientResetPwdTitle = "SFTPGo WebClient - Reset password" + pageClientForgotPwdTitle = "Forgot password" + pageClientResetPwdTitle = "Reset password" pageExtShareTitle = "Shared files" pageUploadToShareTitle = "Upload to share" pageDownloadFromShareTitle = "Download shared file" @@ -665,6 +665,7 @@ func (s *httpdServer) renderClientNotFoundPage(w http.ResponseWriter, r *http.Re func (s *httpdServer) renderClientTwoFactorPage(w http.ResponseWriter, r *http.Request, error, ip string) { data := twoFactorPage{ + Title: pageTwoFactorTitle, CurrentURL: webClientTwoFactorPath, Version: version.Get().Version, Error: error, @@ -682,6 +683,7 @@ func (s *httpdServer) renderClientTwoFactorPage(w http.ResponseWriter, r *http.R func (s *httpdServer) renderClientTwoFactorRecoveryPage(w http.ResponseWriter, r *http.Request, error, ip string) { data := twoFactorPage{ + Title: pageTwoFactorRecoveryTitle, CurrentURL: webClientTwoFactorRecoveryPath, Version: version.Get().Version, Error: error, diff --git a/templates/common/forgot-password.html b/templates/common/forgot-password.html index e7e3fe818c3c0e3bc8f16f7314891c591605d46c..e9401d34420da54566516bfb111c676dd5bbc901 100644 --- a/templates/common/forgot-password.html +++ b/templates/common/forgot-password.html @@ -24,7 +24,7 @@ along with this program. If not, see . - {{.Branding.Name}} - Forgot password + {{.Branding.Name}} - {{.Title}} diff --git a/templates/common/reset-password.html b/templates/common/reset-password.html index 121dc9e14f3474b763a78ca46942a45744a165d1..ee0b32f52a645cd1c53ba1f632d4add0451ceb98 100644 --- a/templates/common/reset-password.html +++ b/templates/common/reset-password.html @@ -24,7 +24,7 @@ along with this program. If not, see . - {{.Branding.Name}} - Reset password + {{.Branding.Name}} - {{.Title}} diff --git a/templates/webadmin/twofactor-recovery.html b/templates/webadmin/twofactor-recovery.html index 6ec7a4d914fae3deddf13c33d05363b819230461..9142acb8b2c582e928dfda28c81940ee997f79a6 100644 --- a/templates/webadmin/twofactor-recovery.html +++ b/templates/webadmin/twofactor-recovery.html @@ -15,7 +15,7 @@ along with this program. If not, see . --> {{template "baselogin" .}} -{{define "title"}}Two-Factor recovery{{end}} +{{define "title"}}{{.Title}}{{end}} {{define "content"}}
diff --git a/templates/webadmin/twofactor.html b/templates/webadmin/twofactor.html index 2c03f7ea7b9685a236a52441d42758b5b12b1fc6..fbaaed61f7dee1d7e8aa0ca3e2d23742a6cb85ed 100644 --- a/templates/webadmin/twofactor.html +++ b/templates/webadmin/twofactor.html @@ -15,7 +15,7 @@ along with this program. If not, see . --> {{template "baselogin" .}} -{{define "title"}}Two-Factor authentication{{end}} +{{define "title"}}{{.Title}}{{end}} {{define "content"}}
diff --git a/templates/webclient/forgot-password.html b/templates/webclient/forgot-password.html index 6a3cecf1442f7a7dd562c8911c67745fe99df8b5..4e2372331c35822fb591bb34514cee86d1885658 100644 --- a/templates/webclient/forgot-password.html +++ b/templates/webclient/forgot-password.html @@ -15,7 +15,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). --> {{- template "baselogin" .}} -{{- define "title"}}Forgot password{{- end}} +{{- define "title"}}{{.Title}}{{- end}} {{- define "content"}}
diff --git a/templates/webclient/reset-password.html b/templates/webclient/reset-password.html index 940439b2cb551966f04ade9be58ac8896f6698d9..7147cd8fd9e510640ebb12e35db2c6e2d2eedd49 100644 --- a/templates/webclient/reset-password.html +++ b/templates/webclient/reset-password.html @@ -15,7 +15,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). --> {{- template "baselogin" .}} -{{- define "title"}}Reset password{{- end}} +{{- define "title"}}{{.Title}}{{- end}} {{- define "content"}} diff --git a/templates/webclient/twofactor-recovery.html b/templates/webclient/twofactor-recovery.html index a3c7bbaf771b7fa3bdb6cbebc7d76c4e2ac436f8..09025e4867949661933b2a5bcd02fdbbcde80049 100644 --- a/templates/webclient/twofactor-recovery.html +++ b/templates/webclient/twofactor-recovery.html @@ -15,7 +15,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). --> {{- template "baselogin" .}} -{{- define "title"}}Two-Factor recovery{{- end}} +{{- define "title"}}{{.Title}}{{- end}} {{- define "content"}} diff --git a/templates/webclient/twofactor.html b/templates/webclient/twofactor.html index f978ecc816be4b6fe21d21c5ce0dcb601fb71a5a..fdbdc9f4b0ef9a764a9f75ebe0a4488c59dd3e8b 100644 --- a/templates/webclient/twofactor.html +++ b/templates/webclient/twofactor.html @@ -15,7 +15,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). --> {{- template "baselogin" .}} -{{- define "title"}}Two-Factor authentication{{- end}} +{{- define "title"}}{{.Title}}{{- end}} {{- define "content"}}