Sitecore:使用社交连接器模块实现登录页面

时间:2013-11-05 10:59:30

标签: sitecore facebook-login social sitecore7 sitecore-social-connected

我正在使用社交连接器模块来集成Facebook登录。

您能否告诉我如何将其整合到一个页面中,当他浏览网站查看任何页面时,将向任何用户显示该页面,一旦他使用他的Facebook凭据登录,将显示该网站的请求页面。

2 个答案:

答案 0 :(得分:0)

如果我理解正确,您想确保在显示任何内容之前通过Facebook登录?
快速浏览Administrators and Developers guide后,我认为您应该可以使用Sitecore Rule

您的Condition将是where the current user is connected to the specific social network,您可以在其中设置'特定'到Facebook。此规则随模块一起提供。您的(自定义)Action可能类似于“将上下文项设置为特定项目”,其中特定项目是您的登录页面(请记住,您可能希望排除该页面以运行Rule到假设您的登录页面也在Sitecore中,则可以防止无限循环。

剩下的就是在页面加载时启动规则。要查看Sitecore如何为此ConditionalRenderingsRules执行此操作,您可以使用Reflector,并在Evaluate中反汇编Sitecore.Pipelines.InsertRenderings.Processors.EvaluateConditions方法。

答案 1 :(得分:0)

你也可以通过代码实现这一目标:

    private void Page_Load(object sender, EventArgs e)
        {
            string fbId;
            if (Request.QueryString["authResult"] != null && IsFacebookLogin(out fbId))
            {
                var facebookDataItem = Sitecore.Context.Database.GetItem("/sitecore/content/Home/FacebookData");
                Response.Redirect(facebookDataItem.Paths.Path.Replace(facebookDataItem.Paths.ParentPath, ""));
            }
        }

public bool IsFacebookLogin(out string fbId)
        {
            fbId = string.Empty;
            if (!Sitecore.Context.User.IsAuthenticated) return false;

            fbId = Sitecore.Context.User.Profile.GetCustomProperty("fb_id");
            return !string.IsNullOrEmpty(fbId);
        }

在这种情况下,如果用户使用Facebook ID登录,我正在进行重定向。 您还可以查看此博客文章,了解有关设置和安装的更多详细信息。模块的用法:Social Connected with Sitecore (Facebook) 1: Setup, Posting messages on content publish & trigger of DMS goals