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

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

Introduction

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

Prototype

String FORGOT_PASSWORD_REMINDER_ATTEMPTS

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

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);/* w ww  . j  a v  a  2s . c  om*/

        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);
    }
}