コード例 #1
0
 @Transactional
 @Override
 public void registerNewUser(User user) {
   HashSet auth = new HashSet();
   auth.add(new AuthorityImpl("ROLE_USER"));
   user.setAuthorities(auth);
   user.setDefaultPageLayout(pageLayoutRepository.getByPageLayoutCode("columns_1"));
   try {
     user.setPassword(new String(PwdUtils.cryptPassword(user.getPassword().toCharArray())));
   } catch (NoSuchAlgorithmException ex) {
     throw new RuntimeException(ex);
   }
   User managedUser = userRepository.save(user);
   createDefaultPages(managedUser);
   createUserHome(managedUser.getUsername());
 }
コード例 #2
0
  @Transactional
  @Override
  public UserAccount registerNewAccount(User user, String type) {
    HashSet auth = new HashSet();
    String accountId = user.getUsername();
    auth.add(new AuthorityImpl("ROLE_USER"));
    user.setAuthorities(auth);
    user.setDefaultPageLayout(pageLayoutRepository.getByPageLayoutCode("columns_1"));
    User managedUser = userRepository.save(user);
    createDefaultPages(managedUser);
    createUserHome(accountId);

    UserAccount uac = new UserAccountImpl();
    uac.setUser(managedUser);
    uac.setAccountId(accountId);
    uac.setAccountType(type);

    return uacRepository.save(uac);
  }