Example usage for com.liferay.portal.kernel.util WebKeys FORGOT_PASSWORD_REMINDER_USER

List of usage examples for com.liferay.portal.kernel.util WebKeys FORGOT_PASSWORD_REMINDER_USER

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys FORGOT_PASSWORD_REMINDER_USER.

Prototype

String FORGOT_PASSWORD_REMINDER_USER

To view the source code for com.liferay.portal.kernel.util WebKeys FORGOT_PASSWORD_REMINDER_USER.

Click Source Link

Usage

From source file:com.liferay.login.web.internal.portlet.action.ForgotPasswordMVCActionCommand.java

License:Open Source License

protected void checkReminderQueries(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

    PortletSession portletSession = actionRequest.getPortletSession();

    int step = ParamUtil.getInteger(actionRequest, "step");

    if (step == 1) {
        checkCaptcha(actionRequest);//from ww  w  .j  ava  2  s  .  c  o  m

        portletSession.removeAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_ATTEMPTS);
        portletSession.removeAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_USER_EMAIL_ADDRESS);
    }

    User user = getUser(actionRequest);

    portletSession.setAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_USER_EMAIL_ADDRESS, user.getEmailAddress());

    actionRequest.setAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_USER, user);

    if (step == 2) {
        Integer reminderAttempts = (Integer) portletSession
                .getAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_ATTEMPTS);

        if (reminderAttempts == null) {
            reminderAttempts = 0;
        } else if (reminderAttempts > 2) {
            checkCaptcha(actionRequest);
        }

        reminderAttempts++;

        portletSession.setAttribute(WebKeys.FORGOT_PASSWORD_REMINDER_ATTEMPTS, reminderAttempts);

        sendPassword(actionRequest, actionResponse);
    }
}