NAV

Customize SSO workflow

SSO workflow can be tailored to specifics of merchant’s website. Check out the available customizations below.

Enable Sign in / Sign out links

Ecwid.OnAPILoaded.add(function() {
    Ecwid.setSignInUrls({
        signInUrl: 'http://my.site.com/signin',
        signOutUrl: 'http://my.site.com/signout' // signOutUrl is optional
    });
});

By default, when SSO is used on a web page, Ecwid hides Sign in and Sign out links in the storefront assuming that the user logs in by means of your site login form. We recommend adding Sign in / Sign out links to your store and link them to your site login form to make login process more convenient for your customers.

This can be done by means of Ecwid.setSignInUrls() API extension, which accepts two parameters:

FieldTypeDescription
signInUrlstringURL where your customer will be redirected to log in to your site
signOutUrlstringURL where your customer will be redirected, when they click the 'Log out’ link in the store. This parameter is optional. If not specified, Ecwid will not show the ’sign out’ link.

When you use setSignInUrls() extension, the customer will be redirected to the specified URL in the following situations:

  • They click the 'Sign in’ link in the product browser
  • They open a secured page inside Product Browser (e.g. ’My account’ page)
  • They go to checkout and your store settings require a user to be registered to place an order

Custom Sign in / Sign out handlers

Customizing of Sign in / Sign out functionality in SSO mode

Ecwid.OnAPILoaded.add(function() {
  Ecwid.setSignInProvider({
    addSignInLinkToPB: function() { return true; },
    signIn: function () { 
      alert('User is logging in!');
      // do something
    },

    canSignOut: function() { return true; },
    signOut: function () { 
      alert('User is signing out');
    }
  });
});

Ecwid SSO API provides a tool for advanced customization of the login functionality in Single Sign-on mode – Ecwid.setSignInProvider() method.

FieldTypeDescription
addSignInLinkToPBbooleanSet it to return true if you need to show 'Sign in’ link inside your store
signInfunctionSpecify function to be called when Ecwid is trying to authorize the customer, when either the 'Sign in’ link is clicked or a secured page is opened inside Product Browser. This function does not accept any arguments nor should return any result.
canSignOutfunction returning true or falseSet it to return true if you need to show 'Sign out’ link inside your store
signOutfunctionThis function is called when canSignOut returns true and the customer clicks the 'Sign out’ link inside the store widget