diff --git a/routes/login_page.go b/routes/login_page.go
index eb3048a..74fc632 100644
--- a/routes/login_page.go
+++ b/routes/login_page.go
@@ -17,9 +17,12 @@ import (
"sunshine.industries/some-automoderation/sessions"
)
-type MainData struct {
+type LoginSectionData struct {
IsRoomExisting bool
}
+type loginPageData struct {
+ LoginSection LoginSectionData
+}
// function to register all http routes for servicing auth pages and logic
func registerLoginRoutes(
@@ -93,14 +96,17 @@ func authedPageMiddleware(
func renderLoginPage(w http.ResponseWriter) {
baseFile := "templates/base.gohtml"
- templFile := "templates/login.gohtml"
- tmpl := template.Must(template.ParseFS(templateFs, templFile, baseFile))
+ pageTempl := "templates/login.gohtml"
+ loginSecion := "templates/login-section.gohtml"
+ tmpl := template.Must(template.ParseFS(templateFs, pageTempl, baseFile, loginSecion))
data := pageData{
Base: baseData{
Title: "login",
},
- Content: MainData{
- IsRoomExisting: false,
+ Content: loginPageData{
+ LoginSection: LoginSectionData{
+ IsRoomExisting: false,
+ },
},
}
@@ -182,7 +188,7 @@ func checkRoomName(templateFs *embed.FS,
if err != nil {
log.Printf("/login/room-name-check error finding room %s\n", err)
}
- var templFile = "templates/login.gohtml"
+ templFile := "templates/login-section.gohtml"
tmpl := template.Must(template.ParseFS(templateFs, templFile))
err = tmpl.ExecuteTemplate(w, "formButton", isFound)
}
@@ -241,7 +247,7 @@ func joinRoomHandler(templateFs *embed.FS,
if (person == rooms.Person{}) {
log.Printf("/login/join room pass correct, new person joins")
// creating a new person with provided password hash
- personPassHash, err := hashPassword(personPass)
+ personPassHash, err := hashPassword(personPass)
person = rooms.Person{
Name: personName,
PasswordHash: personPassHash,
diff --git a/routes/templates/login-section.gohtml b/routes/templates/login-section.gohtml
new file mode 100644
index 0000000..5dfa898
--- /dev/null
+++ b/routes/templates/login-section.gohtml
@@ -0,0 +1,111 @@
+ {{ define "loginSection" }}
+
+ {{ end }}
diff --git a/routes/templates/login.gohtml b/routes/templates/login.gohtml
index 939ce87..cb02b17 100644
--- a/routes/templates/login.gohtml
+++ b/routes/templates/login.gohtml
@@ -33,115 +33,7 @@
Some Automoderation: login page
-
+ {{ template "loginSection" .LoginSection }}
{{ end }}