@Override public Account create(AccountInput input, String authenticationSourceMode) { securityService.checkGlobalFunction(AccountManagement.class); // Creates the account Account account = Account.of( input.getName(), input.getFullName(), input.getEmail(), SecurityRole.USER, authenticationSourceService.getAuthenticationSource(authenticationSourceMode) ); // Saves it account = accountRepository.newAccount(account); // Account groups accountGroupRepository.linkAccountToGroups(account.id(), input.getGroups()); // OK return account; }
public Account update(AccountInput input) { return new Account( id, input.getName(), input.getFullName(), input.getEmail(), authenticationSource, role, accountGroups, authorisations, locked ); }
@Override public Account updateAccount(ID accountId, AccountInput input) { securityService.checkGlobalFunction(AccountManagement.class); // Gets the existing account Account account = getAccount(accountId); // Checks if default admin if (account.isDefaultAdmin() && !StringUtils.equals(account.getName(), input.getName())) { throw new AccountDefaultAdminCannotUpdateNameException(); } // Updates it account = account.update(input); // Saves it accountRepository.saveAccount(account); // Updating the password? if (StringUtils.isNotBlank(input.getPassword())) { accountRepository.setPassword(accountId.getValue(), passwordEncoder.encode(input.getPassword())); } // Account groups accountGroupRepository.linkAccountToGroups(account.id(), input.getGroups()); // OK return getAccount(accountId); }
protected Account doCreateAccount(List<AccountGroup> accountGroups) throws Exception { return asUser().with(AccountManagement.class).call(() -> { String name = uid("A"); return accountService.create( new AccountInput( name, "Test " + name, name + "@test.com", "test", accountGroups.stream().map(Entity::id).collect(Collectors.toList()) ) ); }); }
@Override public Account create(AccountInput input) { Account account = create( input, "password" ); accountRepository.setPassword(account.id(), passwordEncoder.encode(input.getPassword())); return account; }
new AuthenticatedAccount( accountService.create( new AccountInput( name, userDetails.getFullName(),