added authentication among other things. considered working at this point.

This commit is contained in:
2025-03-25 11:27:21 +00:00
parent cf8b0041b2
commit f1ad9757ba
19 changed files with 310 additions and 58 deletions

View File

@@ -1,17 +1,24 @@
package handlers
import (
"html/template"
"log"
"net/http"
"synlotto-website/helpers"
"synlotto-website/models"
"github.com/gorilla/csrf"
)
func Home(w http.ResponseWriter, r *http.Request) {
log.Println("✅ Home hit")
err := Tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
"Page": "index",
tmpl := template.Must(template.ParseFiles(
"templates/layout.html",
"templates/index.html",
))
err := tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
"Data": Draws,
})
if err != nil {
@@ -23,9 +30,15 @@ func Home(w http.ResponseWriter, r *http.Request) {
func NewDraw(w http.ResponseWriter, r *http.Request) {
log.Println("➡️ New draw form opened")
err := Tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
"Page": "new_draw",
"Data": nil,
tmpl := template.Must(template.ParseFiles(
"templates/layout.html",
"templates/new_draw.html",
))
err := tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{
"csrfField": csrf.TemplateField(r),
"Page": "new_draw",
"Data": nil,
})
if err != nil {
log.Println("❌ Template error:", err)