@Override @PreAuthorize("hasPermission(#forumComponentId, 'COMPONENT', 'GeneralPermission.ADMIN')") public void addUserToGroup(long forumComponentId, long userID, long groupID) throws NotFoundException { JCUser jcUser = getDao().get(userID); jcUser.addGroup(groupDao.get(groupID)); this.getDao().saveOrUpdate(jcUser); }
private void copyFieldsFromUserToJCUser(User commonUser, JCUser user) { user.setRole(commonUser.getRole()); user.setAvatar(commonUser.getAvatar()); user.setBanReason(commonUser.getBanReason()); for (Group group : commonUser.getGroups()) { user.addGroup(group); } }
user.addGroup(group);
/** * {@inheritDoc} */ @Override public void activateAccount(String uuid) throws NotFoundException, UserTriesActivatingAccountAgainException { JCUser user = this.getDao().getByUuid(uuid); if (user == null) { LOGGER.warn("Could not activate user with UUID[{}] because it doesn't exist. Either it was removed from DB " + "because too much time passed between registration and activation, or there is an error in link" + ", might be possible the user searches for vulnerabilities in the forum.", uuid); throw new NotFoundException(); } else if (!user.isEnabled()) { Group group = groupDao.getGroupByName(AdministrationGroup.USER.getName()); user.addGroup(group); user.setEnabled(true); this.getDao().saveOrUpdate(user); activateByPlugin(user.getUsername()); LOGGER.info("User [{}] successfully activated", user.getUsername()); } else { LOGGER.warn("User [{}] tried to activate his account again, but that's impossible. Either he clicked the " + "link again, or someone looks for vulnerabilities in the forum.", user.getUsername()); throw new UserTriesActivatingAccountAgainException(); } }