function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Trying to build a code that uses system.resetpassword () method to overwrite the default community password reset Since it is not working due to Winter 16

The code appears to be working from the debug logs and resetting the password internally by clicking on the view button in Visualforce. I am not sure what I am missing:

* An apex page controller that exposes the site forgot password functionality
Global class ForgotPasswordController {
    Global String username {get; set;}   
   Global ForgotPasswordController() {}
    Global PageReference forgotPassword() {
        User usr = [select Id from User where username=:username];
        boolean success = Site.forgotPassword(username);
        PageReference pr = Page.ForgotPasswordConfirm;
        if (success) {
            return pr;
        return null;
     Global static testMethod void testForgotPasswordController() {
        // Instantiate a new controller with all parameters in the page
        ForgotPasswordController controller = new ForgotPasswordController();
        controller.username = '';        

When you go to communities and conduct a password reset outside it does not work why?
<apex:page id="forgotPassword" showHeader="false" controller="ForgotPasswordController" title="{!$}" standardStylesheets="true">
 <apex:composition template="{!$Site.Template}">
    <apex:define name="body">  
        <apex:panelGrid bgcolor="white" columns="1" style="align: center;"> 
          <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="1" style="border:1px solid #ccc;"> 
            <apex:outputPanel layout="block" style="background-color: white; border: 1px solid #ccc; padding: 0px; margin-top: 10px; margin-bottom: 0px; margin-left: 10px; margin-right: 10px;">
              <apex:panelGrid width="758" cellpadding="0" cellspacing="0" bgcolor="white" columns="2"> 
                <apex:image url="{!$Site.Prefix}{!$}/clock.png"/>
                <apex:panelGroup >
                  <apex:outputText style="font-size: larger; font-weight: bold;" value="{!$}"/>
                  <apex:form id="theForm">
                    <apex:messages id="msg" styleClass="errorMsg" layout="table" style="margin-top:1em;"/>
                    <apex:panelGrid columns="3" style="margin-top:1em;">
                      <apex:outputLabel value="{!$}" for="username"/>
                      <apex:inputText required="true" id="username" value="{!username}"/>
                      <apex:commandButton id="submit" value="{!$}" action="{!forgotPassword}"/>
            <c:SiteFooter />