Question

I have a custom portal integrated with a custom site, using Apex/Visualforce. I want to provide custom password change functionality on a Visualforce page that's enabled for the site/portal.

The Site static class method is hardly documented and after combing developerforce.com and coming up empty, I figured I would try here. Here's the method (found in the sample ChangePasswordController class)

Site.changePassword(newPassword, verifyNewPassword, oldpassword);

Here's the kicker. Regardless what data I enter for these values, including respecting all password policies, the method simply returns null and does nothing. It's interesting that in the sample test method provided by Salesforce the assert literally proves this to be the case:

/**
 * An apex page controller that exposes the change password functionality
 */
public with sharing class ChangePasswordController {
    public String oldPassword {get; set;}
    public String newPassword {get; set;}
    public String verifyNewPassword {get; set;}        

    public PageReference changePassword() {
        return Site.changePassword(newPassword, verifyNewPassword, oldpassword);
    }     

    public ChangePasswordController() {}

    public static testMethod void testChangePasswordController() {
        // Instantiate a new controller with all parameters in the page
        ChangePasswordController controller = new ChangePasswordController();
        controller.oldPassword = '123456';
        controller.newPassword = 'qwerty1'; 
        controller.verifyNewPassword = 'qwerty1';                

        System.assertEquals(controller.changePassword(),null);                           
    }    
}

Thanks in advance for any assistance with this!

Was it helpful?

Solution

Do you have an <apex:pageMessages> element on your VF page? Perhaps the Site class is setting an error message, which you wouldn't see unless you have this element on the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top