chore(auth): #331 implement and fix fist sign up tests
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 45s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 51s

This commit was merged in pull request #348.
This commit is contained in:
2024-12-23 22:51:46 +01:00
parent 7a7d7cf204
commit 9462f8b245
3 changed files with 91 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import (
"me-fit/log"
"me-fit/service"
"me-fit/types"
"me-fit/utils"
)
type csrfResponseWriter struct {
@@ -57,7 +58,11 @@ func CrossSiteRequestForgery(auth service.Auth) func(http.Handler) http.Handler
}
if session == nil || csrfToken == "" || !auth.IsCsrfTokenValid(csrfToken, session.Id) {
log.Info("CSRF-Token not correct")
http.Error(w, "CSRF-Token not correct", http.StatusBadRequest)
if r.Header.Get("HX-Request") == "true" {
utils.TriggerToast(w, r, "error", "CSRF-Token not correct", http.StatusBadRequest)
} else {
http.Error(w, "CSRF-Token not correct", http.StatusBadRequest)
}
return
}
}