AEM 6.2 Account Management Service

The AccountManagementService provides a way for a visitor (a non logged-in user) to request a new account or to request a password reset. For any other account management task (e.g. modifying a user property) please use theorg.apache.jackrabbit.api.security.user.UserManager, based on the logged-in user session. The default implementation works as follows: – when a new account is requested, the account is created in the repository and the account is disabled. An email is sent to the user together with a link to confirm the operation. When the link is clicked, the request is validated and if valid the account is enabled. – when a password reset is requested, an email is sent to the user together with a link to confirm the operation. When the link is clicked, , the request is validated and if valid the password is reset and an email is sent to the user with the new password. Other implementations could look as follows: – when a new account is requested, an email is sent to the user together with a link to confirm the operation. The link contains an encrypted token with all the information about the account. When the link is clicked, the account is created. – when a new account is requested, a workflow is triggered. The workflow takes care of validating and creating the new account.

The AccountManagementService provides 2 methods:

 

request-account

 

The requestAccount method will be used by registration process.

Example Registration Implementation:

 

registration-servlet

 

 

Once you submit the registration form, you will get an email in the below format:

 

request-for-account

 

The link points to a confirmation page with “ky” as request parameter. You need to write a confirmation component which reads the “ky” request parameter and verify the key. Below is the sample code.

Confirmationmodule.html (Confirmation component)

 

confirmationmodule

 

 

Line #6 includes a JSP. The JSP does the actual confirmation check. Here is the JSP:

 

accountconfirmation

 

Based on the verification the JSP will display success or failure message accordingly.

Registration Done!

 

Now Password Reset method:

 

requestpasswordreset

 

 

For requesting a password reset, the user needs to enter the user id, here is the sample html form:

 

passwordresetform

 

 

This html form submits the post request to below servlet:

 

passwordresetservlet

 

Once user submits the user id, the user will get an email similar to the below:

 

passwrdresetemail

 

 

When the user clicks on the link, it will be redirected to password confirmation page, where user need to enter the new password and confirm password. Example html below:

 

pwdconfirmpwdform

 

For submitting this form, create a POST.html in the component and include the accountconfirmation.jsp. Sample below:

POST.html

 

posthtml

 

 

Accountconfirmation.jsp

 

pwdconfirmationjsp

 

Based on the verification, the JSP will display Success or failure messages.

Will create a separate post for handling login, session management and permission sensitive caching.

2 responses to “AEM 6.2 Account Management Service”

  1. Ravi Mamidipalli Avatar
    Ravi Mamidipalli

    Generally, we find very few articles on Account Management in AEM. I really appreciate your efforts for clearly written and thought-provoking article.

    Just curious how it has been handled a specific rare scenario – if a user say “Mehenji Rahul Kumar” is trying to register with user name “mhrkumar” and as not clicked the activation email. For another new user say “Mamidipalli Ravi Kumar” when tries to register with the same user name “mhrkumar” an error message that user account does not exists should be displayed before sending an activation email (i.e. validation of the new user name has to happen on the existing accounts and the tokens already send but awaiting for the confirmation. ).

  2. Pooja Avatar
    Pooja

    Really helpfull Article Rahul!!

    Though I am facing some problem while creating an account with this method :

    When I am creating an account using this service it’s not creating the user at path defined in “rep:intermediatePath” and passed in user properties parameter of request account method but at default location.
    Also the password I am sending in method parameter is not getting set but some system generated password is getting set with property name “rep:password”.
    Please let me know if you have any idea about this issue.

Leave a reply to Pooja Cancel reply