Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AccountManagementService : AEM 6.2

Avatar

Level 3

Hello All ,

We are currently working on AccountManagerService For Aem 6.2 as AccountManager and AccountManagerFactory seems to be depreceated.

We have our functional code as below :


            ResourceResolver resourceResolver= request.getResourceResolver();
             adminsession = resourceResolver.adaptTo(Session.class);
            //adminsession = repos.loginService(null, null);
                    //loginAdministrative(null);
        /**///    AccountManager am = af.createAccountManager(adminsession);
            
            String currentPagePath = request.getParameter("currentPagePath");
            log.info("currentPagePath == "+ currentPagePath);
            
            Page currentPage =null;
            Resource currentResource = resourceResolver.getResource(currentPagePath);
            if(currentResource != null){
                log.info("current Resource == "+ currentResource);
                currentPage = currentResource.adaptTo(Page.class);
            }
            log.info("current page == "+ currentPage);
            
            if(currentPage == null){
                currentPage = currentResource.getParent().adaptTo(Page.class);
                log.info("parent page path -->"+currentPage.getPath());
            }
            
            log.info("current page path == "+ currentPage.getPath());
            
            cug_enabled = currentPage.getProperties().get("enableCUG", "false");
            group = currentPage.getProperties().get("cq:cugPrincipals","null");
            redirectURL = currentPage.getProperties().get("cq:cugLoginPage","currentPage");
            

From above can you please suggest on how we can replace AccountManager and AccountManagerFactory methods(highlighted bold) with new interface of AccountManagementService?

Thanks!

0 Replies

Avatar

Level 10

Here is the JavaDocs for this API: 

https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/account/api/AccountManagemen...

I am not sure if we have an example of using this API. I will look to see if there is an example. 

Avatar

Level 8

Do something like this:

AccountManagementService accountManagementService = sling.getService(AccountManagementService.class);  

if (accountManagementService != null) {        try {                      accountManagementService.requestAccount("test","test",null,"test@tes.com","/content/geometrixx/en/toolbar/account/accountrequest.html");    

   } catch (Exception e) {        

   log.error("Error requesting a password request");   

    }