Skip to content

Commit

Permalink
fix: fail fast when user ID is missing in the token info
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Jul 12, 2023
1 parent 42840a1 commit 3d51ed7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/mycarehub/presentation/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ func AuthenticationMiddleware(checkFunc IntrospectFunc) func(http.Handler) http.
return
}

if tokenInfo.UserID == "" {
err := fmt.Errorf("missing user ID")
serverutils.WriteJSONResponse(w, err, http.StatusUnauthorized)
return
}

ctx := context.WithValue(r.Context(), firebasetools.AuthTokenContextKey, &auth.Token{UID: tokenInfo.UserID})

r = r.WithContext(ctx)
Expand Down

0 comments on commit 3d51ed7

Please sign in to comment.