From d0bf1153ada4f933f7db6a4856bfed4785cced14 Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Mon, 30 May 2022 08:06:56 -0400 Subject: [PATCH] webhooks.FilterWebhooks: Filter by user_id --- webhooks/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webhooks/config.go b/webhooks/config.go index af28840eebeec33cb76cacf2aedb2ec391127fae..c5ebbdb426d1aa5579be55a346ca0fbc6dcfb686 100644 --- a/webhooks/config.go +++ b/webhooks/config.go @@ -63,6 +63,7 @@ func NewAuthConfig(ctx context.Context) (AuthConfig, error) { // Returns an SQL expression to filter webhooks for the authenticated user. func FilterWebhooks(ctx context.Context) (sq.Sqlizer, error) { + user := auth.ForContext(ctx) ac, err := NewAuthConfig(ctx) if err != nil { return nil, err @@ -73,8 +74,12 @@ func FilterWebhooks(ctx context.Context) (sq.Sqlizer, error) { sq.Expr(`NOW() at time zone 'utc' < expires`), sq.Expr(`token_hash = ?`, ac.TokenHash), sq.Expr(`client_id = ?`, *ac.ClientID), + sq.Expr(`user_id = ?`, user.UserID), }, nil } else { - return sq.Expr(`NOW() at time zone 'utc' < expires`), nil + return sq.And{ + sq.Expr(`NOW() at time zone 'utc' < expires`), + sq.Expr(`user_id = ?`, user.UserID), + }, nil } }