예제 #1
0
 private void SetupUsers(ScenarioDefinition scenarioDefinition, long scenarioSessionId)
 {
     foreach (var scenarioAccount in scenarioDefinition.Setup.Accounts.Where(a => a.AccountType == AccountType.User))
     {
         long accountId = _accountsService.Create(AccountType.User, scenarioAccount.AccountInfo, "qqq", true);
         _dataAccessService.AddScenarionSessionAccount(scenarioSessionId, accountId);
     }
 }
예제 #2
0
        public Poll RegisterPoll(string name)
        {
            var accountId = _accountsService.Create(DataLayer.Enums.AccountType.IdentityProvider, name, "qqq", true);
            var account   = _accountsService.GetById(accountId);
            var issuer    = account.PublicSpendKey.ToHexString();

            var attributeDefitions = new List <AttributeDefinition> {
                new AttributeDefinition
                {
                    IsRoot        = true,
                    AttributeName = "VoterNumber",
                    SchemeName    = AttributesSchemes.ATTR_SCHEME_NAME_IDCARD,
                    Alias         = "Voter Number"
                }
            };

            attributeDefitions.ForEach(a =>
            {
                var schemeId = _dataAccessService.AddAttributeToScheme(issuer, a.AttributeName, a.SchemeName, a.Alias, a.Description);
                if (a.IsRoot)
                {
                    _dataAccessService.ToggleOnRootAttributeScheme(schemeId);
                }
            });


            var id = _dataAccessService.AddPoll(name, accountId);

            return(FetchPoll(id));
        }
예제 #3
0
        private long CreateIdentityProviderAccount(ExternalIdpDTO externalIdp)
        {
            string pwd = GetDefaultIdpPassword(externalIdp.Name);

            long accountId = _accountsService.Create(AccountType.IdentityProvider, externalIdp.Alias, pwd, true);

            return(accountId);
        }
예제 #4
0
        private InherenceSetting CreateO10Inherence()
        {
            _logger.Info("CreateO10Inherence");
            AccountId = _accountsService.Create(AccountType.ServiceProvider, nameof(O10InherenceService), GetDefaultO10InherencePassword(), true);
            InherenceSetting inherenceSetting = _dataAccessService.AddInherenceSetting(Name, AccountId);

            _logger.LogIfDebug(() => $"[{AccountId}]: {nameof(CreateO10Inherence)} account created");

            return(inherenceSetting);
        }
예제 #5
0
        public IActionResult Post(Account acc)
        {
            var newcon = accountsService.Create(acc);

            if (newcon.Id == Guid.Empty)
            {
                return(StatusCode(500));
            }
            return(Ok(newcon));
        }
예제 #6
0
        private ConsentManagementSettings CreateNewConsentManagementServiceAccount()
        {
            ConsentManagementSettings settings;
            long accountId = _accountsService.Create(AccountType.User, nameof(ConsentManagementService), GetDefaultConsentManagementPassword(), true);

            settings = new ConsentManagementSettings
            {
                AccountId = accountId
            };
            _dataAccessService.SetConsentManagementSettings(settings);
            return(settings);
        }
예제 #7
0
 public IActionResult Register([FromBody] AccountDto accountDto)
 {
     try
     {
         _accountsService.Create((AccountType)accountDto.AccountType, accountDto.AccountInfo, accountDto.Password);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
예제 #8
0
        public IActionResult Create([FromBody] UserAccountDTO accountDTO)
        {
            var account = _mapper.Map <UserAccount>(accountDTO);

            try
            {
                // save
                _userAccountService.Create(account);
                return(Ok());
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
예제 #9
0
        public IActionResult Register([FromBody] RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    Email       = model.Email,
                    Name        = model.Name,
                    PhoneNumber = model.PhoneNumber,
                    PersonType  = Role.User
                };

                // create user
                var u = accountsService.Create(user, model.Password);

                return(Ok(u));
            }

            return(BadRequest(new { message = "User is not registered" }));
        }
        public IActionResult Post(AccountVM accountToCreate)
        {
            var failedValidations = accountToCreate.IsValid();

            if (failedValidations.Any())
            {
                return(BadRequest(new { FailedValidations = failedValidations }));
            }

            //TODO: Add user to authentication server
            string identityProviderId = Guid.NewGuid().ToString();

            IUserAccount userAccount = accountToCreate.ToUserAccount();

            userAccount.IdentityProviderId = identityProviderId;
            userAccount.AccountType        = AccountTypes.RootAccount;

            IUserAccount createdAccount = _accountsService.Create(userAccount);

            return(Ok(createdAccount));
        }
예제 #11
0
        public async Task <ActionResult <CreateAccountResponseViewModel> > Create([FromBody] CreateAccountRequestViewModel createAccountRequestViewModel)
        {
            CreateAccountResponseViewModel createAccountResponseViewModel = await _accountsService.Create(createAccountRequestViewModel);

            return(Ok(createAccountResponseViewModel));
        }
예제 #12
0
 public async Task Execute(string token, CreateAccountCommand command)
 {
     _AccountService.Authenticate(token);
     await _AccountService.Create(command);
 }