Developer forum

Forum » Development » ShopId in logon request

ShopId in logon request

Anders Ebdrup
Reply

Hi DynamicWeb,

We have a DW9 solution with two websites in the same DynamicWeb installation. Both websites use extranet login, but the users need to be separated per website/shop.

Previously, this has worked for us by posting a custom ShopId as part of the login form. This allowed us to control which shop context should be used when authenticating the user.

In the current LogOn method in LogOnHandler, the shop ID is resolved inside the authentication block:

string shopId = PageView.Current()?.Area?.EcomShopId;

This value is then used when calling:

User.Authenticate(username, password, PermissionLevels.Frontend, shopId, true);

However, the OnBeforeExtranetLogin notification is triggered before shopId is resolved:

NotificationManager.Notify(
    Notifications.Standard.User.OnBeforeExtranetLogin,
    new Notifications.Standard.User.OnBeforeExtranetLoginArgs()
    {
        UserName = username,
        Password = password
    });

Would it be possible to move the resolving of shopId higher up in the LogOn method and include it in the OnBeforeExtranetLoginArgs notification?

For example, something along these lines:

string shopId = PageView.Current()?.Area?.EcomShopId;

NotificationManager.Notify(
    Notifications.Standard.User.OnBeforeExtranetLogin,
    new Notifications.Standard.User.OnBeforeExtranetLoginArgs()
    {
        UserName = username,
        Password = password,
        ShopId = shopId
    });

The important part for us is that the notification subscriber would be able to override the shopId before the user is authenticated.

This would make it possible to support cases where the shop context should be controlled by the login form, for example when posting a ShopId from the frontend login form in a multi-site DW9 solution.

Use case:

  • One DW9 solution
  • Two websites/sites in the same installation
  • Extranet users must be separated between the two sites
  • Login form posts ShopId
  • Authentication should use the posted ShopId instead of only relying on PageView.Current()?.Area?.EcomShopId

Is this something that could be added to DW9, so shopId can be adjusted in OnBeforeExtranetLogin before User.Authenticate(...) is called?

Best regards,
Anders


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Anders

The shopid from the login context - you can simply post the login to 2 different pages - pageid:1 and pageid:123 where 123 is a page on your second website where that website contains the correct shopid.

It is worth noting that there are 2 shopids in place - the one for the user which defines if it username from shop1 or shop2 to perform the login for - and that is combined with the second shopid which is the one in the context of the page I am currently logging into.

Adding the shopid as you ask would be a mismatch of context - the shopid would be the website you are logging into - and not the shopid of the user you are logging in as...

 
Anders Ebdrup
Reply

Hi Nicolai,

 

The case here is that we only have one shop, but two different websites (a Danish and a Swedish version), which has to be separated for the users.

How can we achieve this in the current setup, so a user can exists as two different uses based on the language version?

 

Best regards, Anders

 

You must be logged in to post in the forum