示例#1
0
        public void AddExternalUserAccount(Guid userId, AccountType type, string name)
        {
            userContext.CheckPermission(Permissions.UserMaintenance);

            var command = new CreateExternalUserAccountCommand(userId, type, name);

            commandBus.Value.Send(Envelope.Create(command));
        }
示例#2
0
        private void MockUser(CreateExternalUserAccountCommand createExternalUserAccountCommand)
        {
            var user = new User {
                Id = createExternalUserAccountCommand.UserId
            };

            queryService.GetUser(Arg.Is <string>(o => o == createExternalUserAccountCommand.Name),
                                 (Querying.Data.AccountType)AccountType).Returns(user);
        }
示例#3
0
        public void Execute(CreateExternalUserAccountCommand command)
        {
            if (command.Type == Interfaces.Model.AccountType.Password)
            {
                throw new ArgumentException("Account of type 'Password' cannot be created without providing password.");
            }

            ValidateCommand(command);
            AccountType mappedAccountType = Map(command.Type);
            User        user = repository.GetUser(command.UserId);

            ValidateAgainstExistingAccounts(user, command.Type, mappedAccountType, command.Name);

            repository.AddUserAccount(command.UserId, mappedAccountType, command.Name);
            repository.SaveChanges();

            AddAuditTrailEntry(command, user);
        }
示例#4
0
        public Guid AddUser(string accountName, AccountType type, string displayName, IEnumerable <string> authenticatedGroups,
                            IEnumerable <KeyValuePair <string, string> > customProperties)
        {
            Guid userId     = Guid.NewGuid();
            var  properties = customProperties != null?customProperties.ToList() : null;

            var createUserCommand = new CreateUserCommand(userId, displayName, properties);

            commandBus.Value.Send(Envelope.Create(createUserCommand));

            var createAccountCommand = new CreateExternalUserAccountCommand(userId, type, accountName);

            commandBus.Value.Send(Envelope.Create(createAccountCommand));

            SetRolesAndGroups(userId, authenticatedGroups);

            return(userId);
        }