Membership Reboot create/edit new tenant

459 Views Asked by At

In MembershipReboot Documentation described ability use few tenants in app.

<membershipReboot multiTenant="true" defaultTenant="SomeName" />

But there are no examples how to implement crud for tenants using ravendb. Please share link or provide example if you have.

Thank you.

1

There are 1 best solutions below

0
On

If you mean is there a way to CRUD Tenant objects, there isn't any because there isn't any such thing as a tenant object. It's simply a string that operates as a discriminator in the database. You need to pass in your own tenant string.

If you mean creating a user there isn't much too it. You have to implement a RavenDB Repository. (see here Sample RavenDb implementation), then simply call the create method on the UserAccountService

        var securitySettings = new SecuritySettings
        {
            AllowLoginAfterAccountCreation = true,
            MultiTenant = true,
        };

        var config = new MembershipRebootConfiguration<HierarchicalUserAccount>(securitySettings);
        var repository = new RavenUserAccountRepository("");

        var uas = new UserAccountService<HierarchicalUserAccount>(config, repository);

        var userAccount = uas.CreateAccount("tenant_id", "username", "password", "[email protected]");