Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
SchawnnDev committed May 31, 2024
2 parents 2e68e17 + a8fe8d7 commit 34ea827
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions internals/handlers/facts_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,14 @@ func FactToESQuery(w http.ResponseWriter, r *http.Request) {
zap.L().Debug("Debugging fact", zap.Any("f", f))
}

// Add context to fact, replace params and evaluate queries
f.ContextualizeDimensions(t, parameters)
err = f.ContextualizeCondition(t, parameters)
if err != nil {
render.Error(w, r, apiError, err)
return
}

source, err := elasticsearch.ConvertFactToSearchRequestV8(f, t, parameters)
if err != nil {
zap.L().Error("Cannot convert fact to search request", zap.Error(err), zap.Any("fact", f))
Expand Down
9 changes: 8 additions & 1 deletion internals/router/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ func ContextMiddleware(next http.Handler) http.Handler {
return
}

userID, _ := uuid.Parse(rawUserID.(string))
rawUserIDStr, ok := rawUserID.(string)
if !ok {
zap.L().Warn("Cannot parse user ID", zap.Any("claims", claims))
render.Error(w, r, render.ErrAPISecurityMissingContext, errors.New("invalid JWT"))
return
}

userID, _ := uuid.Parse(rawUserIDStr)

user, found, err := users.R().Get(userID)
if err != nil {
Expand Down

0 comments on commit 34ea827

Please sign in to comment.