Skip to content

Commit

Permalink
address PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
  • Loading branch information
golanglemonade committed Dec 4, 2024
1 parent 35b8aa2 commit 1c56ec7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions internal/ent/privacy/policy/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions internal/ent/privacy/policy/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1c56ec7

Please sign in to comment.