Disabling the Attachment of a Visitor’s Social Network Accounts to their Sitecore User Profile

Once your site is configured to enable login using Social Media website logins, when a user logs in for the first time to the site using social media website credentials, one of the following scenarios kick in:

  • The email id does not exist in the corresponding core database, and a new user is created corresponding to this new email id.
  • The email id already exists in the core DB (User Manager) and the social media profile is merely attached to this existing record.

This is the default behavior of the social connected module.
However, depending on the business needs of your site, you might want to override this behavior and provide the ability for a user to have separate logins (site created login and social media credential login).

To override this functionality, we need to override the FacebookLoginButtonOneClick() method which is executed in the ‘~\layouts\system\Social\Connector\Login with Facebook.ascx’ (Sitecore.Social.Facebook.Client.dll – Class:Sitecore.Social.Facebook.Client.Connector.Controls.LoginWithFacebook)
2014-06-30_005944

        protected void FacebookLoginButtonOneClick(object sender, ImageClickEventArgs e)
        {
            const bool updateSocialProfileAsync = true; 
            var connectorClientManager = new ConnectorClientManager();
            if (!Sitecore.Context.User.IsAuthenticated)
            {
                connectorClientManager.LogOnUser("Facebook", new ApplicationCredentials
                {
                    ApplicationKey = "<your app key>", 
                    ApplicationSecret = "<your app secret>"
                },
                updateSocialProfileAsync);
            }
            else
            {
                connectorClientManager.AttachToUser("Facebook", new ApplicationCredentials
                {
                    ApplicationKey = "<your app key>",
                    ApplicationSecret = "<your app secret>"
                }, 
                updateSocialProfileAsync);
            }
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s