public User(
                TenantId tenantId,
                string username,
                string password,
                Enablement enablement,
                Person person)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "The tenantId is required.");
            AssertionConcern.AssertArgumentNotNull(person, "The person is required.");
            AssertionConcern.AssertArgumentNotEmpty(username, "The username is required.");
            AssertionConcern.AssertArgumentLength(username, 3, 250, "The username must be 3 to 250 characters.");

            this.Enablement = enablement;
            this.Person = person;
            this.TenantId = tenantId;
            this.Username = username;

            ProtectPassword("", password);

            person.User = this;

            DomainEventPublisher
                .Instance
                .Publish(new UserRegistered(
                        tenantId,
                        username,
                        person.Name,
                        person.ContactInformation.EmailAddress));
        }
Exemple #2
0
        internal User(
                TenantId tenantId,
                string username,
                string password,
                Enablement enablement,
                Person person)
            : this()
        {
            this.Enablement = enablement;
            this.Person = person;
            this.TenantId = tenantId;
            this.Username = username;

            this.ProtectPassword("", password);

            person.User = this;

            DomainEventPublisher
                .Instance
                .Publish(new UserRegistered(
                        tenantId,
                        username,
                        person.Name,
                        person.ContactInformation.EmailAddress));
        }
        public User RegisterUser(
                string invitationIdentifier,
                string username,
                string password,
                Enablement enablement,
                Person person)
        {
            AssertionConcern.AssertStateTrue(this.Active, "Tenant is not active.");

            User user = null;

            if (this.IsRegistrationAvailableThrough(invitationIdentifier))
            {
                // ensure same tenant
                person.TenantId = this.TenantId;

                user = new User(this.TenantId, username, password, enablement, person);
            }

            return user;
        }