#73 add sign out
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 48s

This commit is contained in:
Tim
2024-08-29 09:24:38 +02:00
parent fe1f47a55e
commit cda672caac
7 changed files with 149 additions and 51 deletions

View File

@@ -1,20 +1,25 @@
package service
import (
"database/sql"
"me-fit/template"
"net/http"
"github.com/a-h/templ"
)
func HandleIndexAnd404(w http.ResponseWriter, r *http.Request) {
var comp templ.Component = nil
if r.URL.Path != "/" {
comp = template.Layout(template.NotFound())
w.WriteHeader(http.StatusNotFound)
} else {
comp = template.Layout(template.Index())
}
func HandleIndexAnd404(db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var comp templ.Component = nil
user_comp := UserInfoComp(verifySessionAndReturnUser(db, r))
comp.Render(r.Context(), w)
if r.URL.Path != "/" {
comp = template.Layout(template.NotFound(), user_comp)
w.WriteHeader(http.StatusNotFound)
} else {
comp = template.Layout(template.Index(), user_comp)
}
comp.Render(r.Context(), w)
}
}