fix context problems

This commit is contained in:
u80864958
2025-05-05 09:00:15 +02:00
parent 14b57b57e8
commit a06444c4df
6 changed files with 29 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ type authkey int
const keyClaims = iota
func writeToContext(r *http.Request, claims *Claims) *http.Request {
ctx := context.WithValue(r.Context(), claims, claims)
ctx := context.WithValue(r.Context(), keyClaims, claims)
return r.WithContext(ctx)
}

View File

@@ -28,6 +28,7 @@ func (s *Service) Authenticated(next http.HandlerFunc, roles ...model.Role) http
w.WriteHeader(http.StatusForbidden)
return
}
r = writeToContext(r, &claims)
next(w, r)
})