about 7 years ago
Hello
Below code will help you to implement change password from custom portlet.
Please follow below steps :
step 1 : create Action URL
<portlet:actionURL name="updatePassword" var="updatePassword"/>
step 2 : Write below code in JSP page
<aui:form method="post" action="<%=updatePassword%>" name="updatepassword" id="updatepassword"> <aui:input label="" name="current" type="text"></aui:input> <aui:input label="" name="password1" type="text"></aui:input> <aui:input label="" name="password2" type="text"></aui:input> <aui:button type="submit" label="" value="Save"></aui:button> </aui:form>
step 3 : Write below Action Class
public void updatePassword(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); String current =uploadRequest.getParameter(actionResponse.getNamespace()+"current"); String password1 =uploadRequest.getParameter(actionResponse.getNamespace()+"password1"); String password2 =uploadRequest.getParameter(actionResponse.getNamespace()+"password2"); logger.info(current+" "+password1+" "+password2); try { long userId=UserLocalServiceUtil.authenticateForBasic(themeDisplay.getCompanyId(), "emailAddress", themeDisplay.getUser().getEmailAddress(), current); if(themeDisplay.getUserId()!=userId) { throw new Exception("Invalid current password."); } if(!password1.equals(password2)) { throw new Exception("Please confirm new password."); } UserLocalServiceUtil.updatePassword(userId, password1, password2, false); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block System.out.println(e.getMessage()); } }
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)