mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
WebUI: extract a common struct for all pages
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -15,7 +15,10 @@
|
||||
package httpd
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/unrolled/secure"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -41,13 +44,17 @@ const (
|
||||
templateCommonBase = "base.html"
|
||||
)
|
||||
|
||||
type commonBasePage struct {
|
||||
CSPNonce string
|
||||
StaticURL string
|
||||
}
|
||||
|
||||
type loginPage struct {
|
||||
commonBasePage
|
||||
CurrentURL string
|
||||
Version string
|
||||
Error string
|
||||
CSRFToken string
|
||||
CSPNonce string
|
||||
StaticURL string
|
||||
AltLoginURL string
|
||||
AltLoginName string
|
||||
ForgotPwdURL string
|
||||
@@ -57,34 +64,31 @@ type loginPage struct {
|
||||
}
|
||||
|
||||
type twoFactorPage struct {
|
||||
commonBasePage
|
||||
CurrentURL string
|
||||
Version string
|
||||
Error string
|
||||
CSRFToken string
|
||||
CSPNonce string
|
||||
StaticURL string
|
||||
RecoveryURL string
|
||||
Title string
|
||||
Branding UIBranding
|
||||
}
|
||||
|
||||
type forgotPwdPage struct {
|
||||
commonBasePage
|
||||
CurrentURL string
|
||||
Error string
|
||||
CSRFToken string
|
||||
CSPNonce string
|
||||
StaticURL string
|
||||
LoginURL string
|
||||
Title string
|
||||
Branding UIBranding
|
||||
}
|
||||
|
||||
type resetPwdPage struct {
|
||||
commonBasePage
|
||||
CurrentURL string
|
||||
Error string
|
||||
CSRFToken string
|
||||
CSPNonce string
|
||||
StaticURL string
|
||||
LoginURL string
|
||||
Title string
|
||||
Branding UIBranding
|
||||
@@ -104,3 +108,10 @@ func getSliceFromDelimitedValues(values, delimiter string) []string {
|
||||
func hasPrefixAndSuffix(key, prefix, suffix string) bool {
|
||||
return strings.HasPrefix(key, prefix) && strings.HasSuffix(key, suffix)
|
||||
}
|
||||
|
||||
func getCommonBasePage(r *http.Request) commonBasePage {
|
||||
return commonBasePage{
|
||||
CSPNonce: secure.CSPNonce(r.Context()),
|
||||
StaticURL: webStaticFilesPath,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user