Issue Type: Bug Bug
Affects Versions: 4.5.6
Assignee: Unassigned
Components: core, security
Created: 30/Jan/13 5:21 PM
Description:

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();
        }
Project: Magnolia
Labels: usermanager core
Priority: Major Major
Reporter: Will Scheidegger
Security Level: Public
Original Estimate: 0.25d
Remaining Estimate: 0.25d
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to