You need to sign in to do that
Don't have an account?
Melliott
Sites Forgot Password Page is not working
I have a site that I we have created that the forgot password link is not working. When you put in the username and click submit, it just sits there. The ForgotPassword Confirm page does not display nor does the email get sent. This is the standard Forgot Password pages and controller that was built when the site was created so they are standard pages.
Any help is greatly appreciated. This is an urgent project we are trying to roll and it's driving me insane.
Code for the page is here.
<apex:page id="Registration" showHeader="false" controller="ForgotPasswordController" title="{!$Label.site.forgot_password}"> <apex:stylesheet value="{!URLFOR($Resource.CP_Site_Resources, 'main.css')}"/> <apex:composition template="CPSiteTemplate"> <apex:define name="body"> <div id="mainouter"> <div id="maininner" align="center"> <apex:form id="theForm" forceSSL="true"> <apex:panelGrid columns="2" style="margin-top:1em;"> <apex:outputLabel value="{!$Label.site.username}" for="username"/> <apex:inputText required="true" id="username" value="{!username}"/> <apex:commandButton id="submit" value="{!$Label.site.submit}" action="{!forgotPassword}"/> </apex:panelGrid> </apex:form> <!-- Closing maininner Div here --> </div> <!-- closing mainouter Div here --> </div> </apex:define> </apex:composition> </apex:page>
/** * An apex page controller that exposes the site forgot password functionality */ public class ForgotPasswordController { public String username {get; set;} public ForgotPasswordController() {} public PageReference forgotPassword() { boolean success = Site.forgotPassword(username); PageReference pr = Page.ForgotPasswordConfirm; pr.setRedirect(true); system.debug(success); if (success) { return pr; } return null; } public static testMethod void testForgotPasswordController() { // Instantiate a new controller with all parameters in the page ForgotPasswordController controller = new ForgotPasswordController(); controller.username = 'test@salesforce.com'; System.assertEquals(controller.forgotPassword(),null); } }
Reminds me of this...
https://xkcd.com/979/
"What did you see Melliott?"
Just understood what I was doing wrong.
1) When I was opening the Forgot password VF page for previewing in Salesforce org then it was not sending the email to reset the password.
2) When I opened the same VF page in the Force.com Site / Community / Customer Portal and then reset the password then it sent me a reset email.
May be Salesforce does not send the reset email when you are previewing the VF page in Salesforce but when you will open the VF page in Force.com Site / Community / Customer Portal and then reset the password then it will send you a reset email if everything is fine.