apex-code - 难以让 Site.changePassword() 工作

标签 apex-code visualforce

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

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

Site.changePassword(newPassword, verifyNewPassword, oldpassword);

这是踢球者。无论我为这些值输入什么数据,包括遵守所有密码策略,该方法都只返回 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);                           
    }    
}

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

最佳答案

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

关于apex-code - 难以让 Site.changePassword() 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8362674/

相关文章:

testing - 在 Salesforce 中测试返回 PageReference 的方法

syntax - VisualForce IF 语句 - 需要了解 "or"的语法

css - Salesforce Visualforce CSS 固定 div

javascript - Salesforce:URL 重写器和 JScript 远程处理:解析 json 响应时出现异常: 'Unexpected token <' 。登录?

salesforce - VisualForce 中的嵌套表问题

salesforce - 如何在 VisualForce 页面中实现 "Save & New"功能

Salesforce 顶点 : ISO Timestamp Format Function

oauth - 我的应用程序(由 salesforce 加载的 iframe)如何确认用户已登录到 salesforce?

csv - 带有自定义 sObject 的 Test.loadData 引发异常

Salesforce (VisualForce) : How to test for no records returned in 'apex:repeat' statement?