@Override @Transactional(readOnly = false) public void register(@NotNull PlayerRegistrationData registrationData) { final Account emailAccount = accountBO.getByEmail(registrationData.getEmail()); if (emailAccount != null) { throw new NotUniqueEmailException("Not unique email!"); } final Player player = new Player(); player.setStatus(Player.Status.REGISTRATION); player.setBirth(registrationData.getBirth()); player.setGender(registrationData.getGender()); player.setName(registrationData.getName()); insert(player); // create account final PlayerAccount account = createAccount(registrationData, player); // create authorities authorityDAO.create(account, Authority.Name.ROLE_PLAYER_USER); notifyOfRegistration(registrationData); }
private PlayerAccount createAccount(PlayerRegistrationData registrationData, Player player) { final PlayerAccount account = new PlayerAccount(); account.setPlayer(player); account.setEmail(registrationData.getEmail()); account.setEnabled(true); account.setPassword(registrationData.getPassword()); accountBO.encodePassword(account); playerAccountDAO.insert(account); return account; }