Fix lint issues in connect v1 resolvers
Drop the redundant embedded Resolver selector flagged by staticcheck (QF1008) in the membership and organization permission resolvers, and add the whitespace wsl_v5 expects around the attribute range loop and the final return in permission. Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
@@ -45,7 +45,7 @@ func (r *membershipResolver) LastSession(ctx context.Context, obj *types.Members
|
||||
|
||||
// Permission is the resolver for the permission field.
|
||||
func (r *membershipResolver) Permission(ctx context.Context, obj *types.Membership, action string, attributes map[string]any) (bool, error) {
|
||||
return r.Resolver.permission(ctx, obj, action, attributes)
|
||||
return r.permission(ctx, obj, action, attributes)
|
||||
}
|
||||
|
||||
// UpdateMembership is the resolver for the updateMembership field.
|
||||
|
||||
@@ -359,7 +359,7 @@ func (r *organizationResolver) Viewer(ctx context.Context, obj *types.Organizati
|
||||
|
||||
// Permission is the resolver for the permission field.
|
||||
func (r *organizationResolver) Permission(ctx context.Context, obj *types.Organization, action string, attributes map[string]any) (bool, error) {
|
||||
return r.Resolver.permission(ctx, obj, action, attributes)
|
||||
return r.permission(ctx, obj, action, attributes)
|
||||
}
|
||||
|
||||
// Organization returns schema.OrganizationResolver implementation.
|
||||
|
||||
@@ -134,6 +134,7 @@ func (r *Resolver) Permission(ctx context.Context, obj types.Node, action string
|
||||
|
||||
func (r *Resolver) permission(ctx context.Context, obj types.Node, action string, attributes map[string]any) (bool, error) {
|
||||
opts := []authz.AuthorizeFuncOption{authz.WithDryRun()}
|
||||
|
||||
for key, value := range attributes {
|
||||
if s, ok := value.(string); ok {
|
||||
opts = append(opts, authz.WithAttr(key, s))
|
||||
@@ -141,6 +142,7 @@ func (r *Resolver) permission(ctx context.Context, obj types.Node, action string
|
||||
}
|
||||
|
||||
_, err := r.authorize(ctx, obj.GetID(), action, opts...)
|
||||
|
||||
return err == nil, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user