Open magnomp opened 7 years ago
Ideally the same super class should be used (so that we're not repeating code), but that's not possible because RestfulController uses @Transaction which don't handles multi tenancy.
Instead it should be something like:
class ScaffoldedController<T> { def delete() { resource.withTransaction { transactionStatus -> } } }
class TenantAwareScaffoldedController<T> extends ScaffoldedController<T> { @Override def delete() { Tenants.withCurrent { super.delete() } } }
As GORM 6 has support for multi tenancy, scaffolded controllers for multi tenant domains should take into account the current tenant, which RestfulController (the super class for scaffolded controllers) don't.
ScaffoldingControllerInjector should detect that: 1) GORM 6 is being used 2) The scaffold property points to a domain class that implements MultiTenancy
If "1" and "2" are true, then the super class must be something that exposes the same actions as RestfulController but whose actions are tenant id aware, like:
def delete() { Tenants.withCurrent { resource.withTransaction { transactionStatus -> ... } } }
If "1" or "2" are false then should behave as today