tbs
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 37s

This commit is contained in:
2024-12-04 23:15:40 +01:00
parent 5ef59df2d0
commit 8aeb284d30
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package middleware
import (
"me-fit/service"
"net/http"
)
func UserAuth(service *service.AuthService) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Check the user is logged in
sessionToken := r.Header.Get("X-Session-Token")
if sessionToken == "" {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
next.ServeHTTP(w, r)
})
}
}