From 1c56ec713cf133e1e44a9a2fcc2b8da947ab7531 Mon Sep 17 00:00:00 2001 From: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:55:29 -0700 Subject: [PATCH] address PR feedback Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com> --- internal/ent/privacy/policy/base.go | 16 ++++++++-------- internal/ent/privacy/policy/checks.go | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/ent/privacy/policy/base.go b/internal/ent/privacy/policy/base.go index 4bf04995..4c2252ef 100644 --- a/internal/ent/privacy/policy/base.go +++ b/internal/ent/privacy/policy/base.go @@ -95,18 +95,18 @@ func NewPolicy(opts ...PolicyOption) ent.Policy { } } -func (policies policies) queryPolicy() privacy.QueryPolicy { - policy := append(privacy.QueryPolicy(nil), policies.pre.Query...) - policy = append(policy, policies.query...) - policy = append(policy, policies.post.Query...) +func (p policies) queryPolicy() privacy.QueryPolicy { + policy := append(privacy.QueryPolicy(nil), p.pre.Query...) + policy = append(policy, p.query...) + policy = append(policy, p.post.Query...) return policy } -func (policies policies) mutationPolicy() privacy.MutationPolicy { - policy := append(privacy.MutationPolicy(nil), policies.pre.Mutation...) - policy = append(policy, policies.mutation...) - policy = append(policy, policies.post.Mutation...) +func (p policies) mutationPolicy() privacy.MutationPolicy { + policy := append(privacy.MutationPolicy(nil), p.pre.Mutation...) + policy = append(policy, p.mutation...) + policy = append(policy, p.post.Mutation...) return policy } diff --git a/internal/ent/privacy/policy/checks.go b/internal/ent/privacy/policy/checks.go index e52675b1..372d3407 100644 --- a/internal/ent/privacy/policy/checks.go +++ b/internal/ent/privacy/policy/checks.go @@ -38,7 +38,7 @@ func CheckOrgWriteAccess() privacy.MutationRule { // DenyQueryIfNotAuthenticated denies a query if the user is not authenticated func DenyQueryIfNotAuthenticated() privacy.QueryRule { return privacy.QueryRuleFunc(func(ctx context.Context, q ent.Query) error { - if _, err := auth.GetAuthenticatedUserContext(ctx); err != nil { + if res, err := auth.GetAuthenticatedUserContext(ctx); err != nil || res == nil { log.Err(err).Msg("unable to get authenticated user context") return err @@ -51,7 +51,7 @@ func DenyQueryIfNotAuthenticated() privacy.QueryRule { // DenyMutationIfNotAuthenticated denies a mutation if the user is not authenticated func DenyMutationIfNotAuthenticated() privacy.MutationRule { return privacy.MutationRuleFunc(func(ctx context.Context, m ent.Mutation) error { - if _, err := auth.GetAuthenticatedUserContext(ctx); err != nil { + if res, err := auth.GetAuthenticatedUserContext(ctx); err != nil || res == nil { log.Err(err).Msg("unable to get authenticated user context") return err