-
Bug
-
Resolution: Won't Do
-
Major
-
None
-
4.5.6
Users cannot be deleted anymore. MgnlUser.getUserNode() is deprecated in a harsh way (throwing an UnsupportedOperationException) and its JavaDoc links to wrong replacement methods. When looking at the user manager classes, no methods to delete users can be found and the methods that could help you get the job done are protected. The following ugly hack solves the problem, but... seriously?
Ugly hack to delete a user
UserManager userManager = SecuritySupport.Factory.getInstance().getUserManager(userManagerName); // get the existing user MgnlUser user = (MgnlUser) userManager.getUser("some_username"); if (user != null) { Method method = MgnlUserManager.class.getDeclaredMethod("getRepositoryName", new Class[0]); method.setAccessible(true); String repositoryName = (String) method.invoke(userManager, new Object[0]); Session session = MgnlContext.getJCRSession(repositoryName); method = MgnlUserManager.class.getDeclaredMethod("findPrincipalNode", String.class, Session.class); method.setAccessible(true); Node userNode = (Node) method.invoke(userManager, user.getName(), session); if (activateUserAfterModification()) { // Are we on the author instance? if (ServerConfiguration.getInstance().isAdmin()) { deactivateUser(user); } } userNode.remove(); session.save(); }
Acceptance criteria