难以让 Site.changePassword() 工作

Ada*_*dam 4 visualforce apex-code

我有一个自定义门户与自定义站点集成,使用 Apex/Visualforce。我想在为站点/门户启用的 Visualforce 页面上提供自定义密码更改功能。

Site 静态类方法几乎没有文档记录,在结合 developerforce.com 并发现空之后,我想我会在这里尝试。这是方法(在示例 ChangePasswordController 类中找到)

Site.changePassword(newPassword, verifyNewPassword, oldpassword);
Run Code Online (Sandbox Code Playgroud)

这是踢球者。无论我为这些值输入什么数据,包括遵守所有密码策略,该方法都会简单地返回 null 并且什么都不做。有趣的是,在 Salesforce 提供的示例测试方法中,断言字面上证明了这种情况:

/**
 * 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);                           
    }    
}
Run Code Online (Sandbox Code Playgroud)

在此先感谢您提供的任何帮助!

Jer*_*oss 5

<apex:pageMessages>你的 VF 页面上有元素吗?也许 Site 类正在设置一条错误消息,除非页面上有此元素,否则您将看不到该消息。