CHANGE: added report section

This commit is contained in:
2025-02-26 15:05:50 +01:00
parent 0ddca8b9ce
commit 54104d5a0e
15 changed files with 376 additions and 96 deletions

View File

@@ -3,6 +3,8 @@ package helper
import (
"net/http"
"os"
"github.com/alexedwards/scs/v2"
)
// setting cors, important for later frontend use
@@ -15,3 +17,13 @@ func SetCors(w http.ResponseWriter) {
w.Header().Set("Access-Control-Allow-Headers", "*")
}
}
func RequiresLogin(session *scs.SessionManager, w http.ResponseWriter, r *http.Request) {
if GetEnv("GO_ENV", "production") == "debug" {
return
}
if session.Exists(r.Context(), "user") {
return
}
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
}