fix(middleware): return *uint from GetUserIDFromContext for nil when unauthenticated

This commit is contained in:
2026-05-06 20:07:41 +02:00
parent 4e188eb8d5
commit dccf85e038
+4 -3
View File
@@ -73,9 +73,10 @@ func NewAuth(verifier TokenVerifier) func(http.Handler) http.Handler {
} }
} }
func GetUserIDFromContext(ctx context.Context) uint { func GetUserIDFromContext(ctx context.Context) *uint {
if userID, ok := ctx.Value(UserIDKey).(uint); ok { if userID, ok := ctx.Value(UserIDKey).(uint); ok {
return userID u := userID
return &u
} }
return 0 return nil
} }