Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)

Home Page:http://hobocentral.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deleting from a has_many_through association improperly fails permission checks

stevemadere opened this issue · comments

There is a bug in ActiveRecord::Associations::HasManyAssociation#delete_records_with_hobo_permission_check
that causes deletion from has_many_through associations to fail when the delete_permitted
implementation depends on the associated object.

Basically, it checks the permissions on an almost randomly selected member of the join table
because it applies only half of the conditions necessary to find the correct joiner record.

The default implementation of destroy_permitted? hides this problem since it only
depends on the user and not at all on the object being destroyed. Thus, it does not
care that it is checking permissions on the wrong instance.

I'll submit a PR with a fix that solves the problem by basing the query off of the
through_association rather than the model.

Fix was merged