List of usage examples for com.liferay.portal.util PropsValues USERS_REMINDER_QUERIES_ENABLED
boolean USERS_REMINDER_QUERIES_ENABLED
To view the source code for com.liferay.portal.util PropsValues USERS_REMINDER_QUERIES_ENABLED.
Click Source Link
From source file:com.liferay.login.web.internal.portlet.action.ForgotPasswordMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isSendPassword() && !company.isSendPasswordResetLink()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_SEND_PASSWORD, PropsKeys.COMPANY_SECURITY_SEND_PASSWORD_RESET_LINK); }// w ww. jav a 2s .c o m try { if (PropsValues.USERS_REMINDER_QUERIES_ENABLED) { checkReminderQueries(actionRequest, actionResponse); } else { checkCaptcha(actionRequest); sendPassword(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass()); } else if (e instanceof NoSuchUserException || e instanceof RequiredReminderQueryException || e instanceof SendPasswordException || e instanceof UserActiveException || e instanceof UserLockoutException || e instanceof UserReminderQueryException) { if (PropsValues.LOGIN_SECURE_FORGOT_PASSWORD) { sendRedirect(actionRequest, actionResponse, null); } else { SessionErrors.add(actionRequest, e.getClass(), e); } } else { _portal.sendError(e, actionRequest, actionResponse); } } }
From source file:com.liferay.login.web.internal.portlet.action.ForgotPasswordMVCActionCommand.java
License:Open Source License
protected void sendPassword(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); User user = getUser(actionRequest);/*from ww w. j a va 2s . c om*/ if (PropsValues.USERS_REMINDER_QUERIES_ENABLED) { if (PropsValues.USERS_REMINDER_QUERIES_REQUIRED && !user.hasReminderQuery()) { throw new RequiredReminderQueryException( "No reminder query or answer is defined for user " + user.getUserId()); } String answer = ParamUtil.getString(actionRequest, "answer"); String reminderQueryAnswer = user.getReminderQueryAnswer(); if (!reminderQueryAnswer.equals(answer)) { throw new UserReminderQueryException("Reminder query answer does not match answer"); } } PortletPreferences portletPreferences = actionRequest.getPreferences(); String languageId = LanguageUtil.getLanguageId(actionRequest); String emailFromName = portletPreferences.getValue("emailFromName", null); String emailFromAddress = portletPreferences.getValue("emailFromAddress", null); String emailToAddress = user.getEmailAddress(); String emailParam = "emailPasswordSent"; if (company.isSendPasswordResetLink()) { emailParam = "emailPasswordReset"; } String subject = portletPreferences.getValue(emailParam + "Subject_" + languageId, null); String body = portletPreferences.getValue(emailParam + "Body_" + languageId, null); LoginUtil.sendPassword(actionRequest, emailFromName, emailFromAddress, emailToAddress, subject, body); HttpServletRequest request = _portal.getHttpServletRequest(actionRequest); SessionMessages.add(request, "passwordSent"); sendRedirect(actionRequest, actionResponse, null); }
From source file:com.liferay.portlet.login.action.ForgotPasswordAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {//from ww w . j a va 2s.c o m if (PropsValues.USERS_REMINDER_QUERIES_ENABLED) { checkReminderQueries(actionRequest, actionResponse); } else { checkCaptcha(actionRequest); sendPassword(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof CaptchaTextException || e instanceof NoSuchUserException || e instanceof RequiredReminderQueryException || e instanceof SendPasswordException || e instanceof UserActiveException || e instanceof UserEmailAddressException || e instanceof UserReminderQueryException) { SessionErrors.add(actionRequest, e.getClass().getName()); } else { PortalUtil.sendError(e, actionRequest, actionResponse); } } }
From source file:com.liferay.portlet.login.action.ForgotPasswordAction.java
License:Open Source License
protected void sendPassword(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); User user = getUser(actionRequest);//from w w w . ja va 2s. c o m if (PropsValues.USERS_REMINDER_QUERIES_ENABLED) { if (PropsValues.USERS_REMINDER_QUERIES_REQUIRED && !user.hasReminderQuery()) { throw new RequiredReminderQueryException( "No reminder query or answer is defined for user " + user.getUserId()); } String answer = ParamUtil.getString(actionRequest, "answer"); if (!user.getReminderQueryAnswer().equals(answer)) { throw new UserReminderQueryException(); } } PortletPreferences preferences = actionRequest.getPreferences(); String languageId = LanguageUtil.getLanguageId(actionRequest); String emailFromName = preferences.getValue("emailFromName", null); String emailFromAddress = preferences.getValue("emailFromAddress", null); String emailToAddress = user.getEmailAddress(); String emailParam = "emailPasswordSent"; if (company.isSendPasswordResetLink()) { emailParam = "emailPasswordReset"; } String subject = preferences.getValue(emailParam + "Subject_" + languageId, null); String body = preferences.getValue(emailParam + "Body_" + languageId, null); LoginUtil.sendPassword(actionRequest, emailFromName, emailFromAddress, emailToAddress, subject, body); sendRedirect(actionRequest, actionResponse); }