private void RegisterAdministratorFor(Tenant tenant, FullName administorName, EmailAddress emailAddress, PostalAddress postalAddress, Telephone primaryTelephone, Telephone secondaryTelephone) { RegistrationInvitation invitation = tenant.OfferRegistrationInvitation("init").OpenEnded(); string strongPassword = new PasswordService().GenerateStrongPassword(); User admin = tenant.RegisterUser(invitation.InvitationId, "admin", strongPassword, Enablement.IndefiniteEnablement(), new Person(tenant.TenantId, administorName, new ContactInformation(emailAddress, postalAddress, primaryTelephone, secondaryTelephone))); tenant.WithdrawInvitation(invitation.InvitationId); _userRepository.Add(admin); Role adminRole = tenant.ProvisionRole("Administrator", "Default" + tenant.Name + " administrator."); adminRole.AssignUser(admin); _roleRepository.Add(adminRole); DomainEventPublisher.Instance.Publish(new TenantAdministratorRegistered(tenant.TenantId, tenant.Name, administorName, emailAddress, admin.UserName, strongPassword)); }
protected Role CreateRole(Tenant tenant) { return tenant.ProvisionRole("Test role", "A test role.", true); }