我想创建一个带有Force.com站点页面的外联网,其中包含允许访问SalesForce.com用户的身份验证。
常见问题解答表明有可能: http://wiki.developerforce.com/index.php/Sites_FAQ
我尝试使用http://wiki.developerforce.com/index.php/Authenticating_Users_on_Force.com_Sites,但只允许客户登录并重定向到客户门户网站。
但是,我需要的是在Force.com Sites上验证SalesForce.com用户。任何的想法 ?有没有办法做到这一点?
答案 0 :(得分:0)
您引用的Wiki页面(http://wiki.developerforce.com/index.php/Authenticating_Users_on_Force.com_Sites)是此处的方法,只需更改以下代码段:
public class SiteLoginController {
public String username {get; set;}
public String password {get; set;}
public PageReference login() {
String startUrl = '/my_site_homepage'; // change the startUrl
return Site.login(username, password, startUrl);
}
public SiteLoginController () {}
public static testMethod void testSiteLoginController () {
// Instantiate a new controller with all parameters in the page
SiteLoginController controller = new SiteLoginController ();
controller.username = 'test@salesforce.com';
controller.password = '123456';
System.assertEquals(controller.login(),null);
}
}
正如您在PageReference login
中看到的那样,您只需将startUrl
更改为您要在登录后加载的页面。