[APIM] Send emails to users upon self-sign up aproval

When using the self sign up of WSO2 API manager, the user needs to wait for the admin to approve their signup request. However when the admin approves/rejects the request, users may like to receive an email with the status of the approval. This can be achieved by the extension points provided by APIM. In this article we will consider how this can be achieved,

First step is to set up the user sign up work flow as described in the documentation[1]. After following the documentation, you should be able to self sign up and attach a workflow to the to the self sign up process. After self signup, you can login to the admin portal of APIM and approve or reject a request to sign up.
This portal can be address through https://HOSTNAME:PORT/admin for example https://10.100.9.174:9443/admin
Next we need to extend from UserSignUpWSWorkflowExecutor of APIM and write your own logic to send out an email. In this case, we have overriden the complete method of UserSignUpWSWorkflowExecutor. In the default implementation, when admin approves or rejects the request and the comple method is called to either delete the user or grant him permission to login. Since this logic is still needed, super.comple() method is first called. Afterwards, the using javax.mail, the mail is constructed as bellow,


Next step is to find the email of the user that this message needs to be delivered to and for this, it is possible use UserStoreManager class as bellow,


You can find the complete code, in github[2] and clone this and compile the code. After compiling, copy the file /target/custom-usersignup-workflow-executor-1.0.0.jar to /repository/components/lib directory

Startup the APIM server and go to the management console(https://:9443/carbon)
Click on browse under resource and go to the following resource/_system/governance/apimgt/applicationdata/workflow-extensions.xml
Add the following section[3] to the workflow-extensions.xml


Comment out org.wso2.carbon.apimgt.impl.workflow.UserSignUpSimpleWorkflowExecutor tag in workflow-extensions.xml.
Now when you sign up and approve, an email should come to the email address of the newly signed up user's provided email.

[1]. https://docs.wso2.com/display/AM210/Adding+a+User+Signup+Workflow
[2]. https://github.com/inoshperera/workflow-executor
[3]. https://github.com/inoshperera/workflow-executor/blob/master/wf.xml#L36-L43

Comments

  1. Interesting Article. Hoping that you will continue posting an article having a useful information. IOS Development

    ReplyDelete

Post a Comment

Popular posts from this blog

MDM vendor singing and MDM APNS certificate generation for WSO2 Iot server

Android device owner concepts

iOS device policies in WSO2 Device cloud