How to make Restful web service api support user email notification feature

* How to implement user email notification feature
* use Amazon Simple Email Service(SES) to send email messages to users programatically
* create email notification links that expire in certain amount of days or hours
* confirm user email address




Spring Security, Make email verification a PUBLIC web service endpoint - not require authorization header
(HTTP GET request whose URL contains verification token as query string)

1.go to WebSecurity.java, and modify configure by adding antMatchers  for Verification Email RUL
2.add constant to SecurityConstants.java


Receive HTTP GET reqeust and read email verification token from url
1, verifyEmailToken() in RestController.
Add verifyEmailToken() Service to Service Layer Function
Add findUserByEmailVerificationToken() to Data Layer function

Add hasTokenExpired() to Utils class



Generate and Save the emai verification token in our DB
1. add the followings to createUser in userServiceImpl
userEntity.setEmailVerificationToken(utils.generateEmailVerificationToken(publicUserId));
userEntity.setEmailVerificationStatus(false);

2. add generateEmailVerificationToken(publicID) to Utils.

3. Create a new user and test the email token generation with specific Url









Comments

Popular posts from this blog

Portlet Edit Mode (Portlet preference) to replace Portlet configuration

GoGo Shell & What can be deleted in Liferay Instance