Single Sign-on

When you need to log in a customer from another system, you can easily make a Single Sign-on page that finds or creates a customer and log them into your e-commerce site.

Login to StormApi is done with StormContext.LoginUser (loginName, rememberMe). Then the cookie will be set to keep track of which customer and account are logged in. As you can see, you do not enter a password to log in. This is to accomodate Single Signon solutions.

Normally when you log in, you call StormApi.CustomerService.Login(login name, password). If you get an approved login from StormApi, you call StormContext.LoginUser (loginName, rememberMe) to save the user information in the cookie. When calling StormApi then you must enter user information from the Cookie when the Api call asks for it. What is needed there to be sent to the Storm API is AccountId, CustomerId, CompanyId, DivisionId, BasketId, CurrencyId, SalesAreaId and CultureCode.

But say that you are from an external login and can identify Storm users with code (the most common for single sign-on) or email, instead, use one of the following GetCustomer:

var customer = client.GetCustomerByCode (externalCode, StormContext.CultureCode)


var customer = client.GetCustomerByEmail (externalEmail, StormContext.CultureCode)

If you receive a customer, you will also get information about the client’s account in Storm. If there are no account, you need to add one to the customer and call StormApi.CustomerService.UpdateCustomer3. If the customer is not available, you can in the Single Sign-on procedure create the customer in Storm with StormApi.CustomerService.CreateCustomer3. Then log in with StormContext.LoginUser (customer.Account.LoginName, false).