Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make scaffolded actions tenant id aware #35

Open
magnomp opened this issue Dec 20, 2016 · 1 comment
Open

Make scaffolded actions tenant id aware #35

magnomp opened this issue Dec 20, 2016 · 1 comment

Comments

@magnomp
Copy link

magnomp commented Dec 20, 2016

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

@magnomp
Copy link
Author

magnomp commented Dec 20, 2016

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() } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant