Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » Extranet users cant login.

Extranet users cant login.

Simon Nordahl
Simon Nordahl
Reply

Hi

We're used to having our customers logging in async through ajax post and a generic handler:

var loginHandler = new Dynamicweb.Frontend.LoginHandler();

loginHandler.ExtranetLogOn(username, password, true);

We're getting nullreference exception in the extranet loginhandler:

   at Dynamicweb.Frontend.LoginHandler.ExtranetLogin(String username, String password, Boolean onlyActive, Boolean impersonateUser, Int32 impersonateUserID, Boolean loginIfPwdEncrypted) in C:\Code\DynamicwebSource\Dynamicweb9\06 - Dynamicweb Host\Dynamicweb\Dynamicweb-9.2\Dynamicweb\Frontend\LoginHandler.vb:line 499
   at Dynamicweb.Frontend.LoginHandler.ExtranetLogOn(String username, String password, Boolean onlyActive) in C:\Code\DynamicwebSource\Dynamicweb9\06 - Dynamicweb Host\Dynamicweb\Dynamicweb-9.2\Dynamicweb\Frontend\LoginHandler.vb:line 367

In the following code:

If Converter.ToBoolean(SystemConfiguration.Instance.GetValue("/Globalsettings/Ecom/Users/IncludeShopIdInExtranetLogIn")) Then
    If Not String.IsNullOrWhiteSpace(Frontend.PageView.Current.Area.EcomShopId) Then
        .Add("AND (")
        .Add("          ( [AccessUser].[AccessUserShopID] = {0} )", Frontend.PageView.Current.Area.EcomShopId)
        .Add("      OR  ( [AccessUser].[AccessUserShopID] IS NULL )")
        .Add("      OR  ( [AccessUser].[AccessUserShopID] = {0} )", "")
        .Add(")")
    End If
End
If

All because we dont have a pageview in the current context despite having IRequiresSessionState on our handler.

In DW8 we made a workaround and called, Dynamicweb.Frontend.PageView.GetPageview(); before we instantiated the the loginhandler.

However thats no longer possible because you for some odd reason have a check in GetPage(underlined):

Public Function GetPage(pageId As Integer) As Page Implements IPageService.GetPage
    Ensure.Argument.Is(pageId > 0, $"GetPage requires a page ID greater than zero, page ID was {pageId}")

    Dim page As Page = Nothing
    If PageIndex.TryGetValue(pageId, page) Then
        Return page
    End If

    page = Repository.GetPage(pageId)
    If page IsNot Nothing Then
        UpdateIndexes(page)
    End If
    Return page
End Function

How would you suggest that we allow our users to log in through ajax post? 

Ideally it should never be nesserary to call GetPageView(), before calling ExtranetLogOn on the loginhandler, but i can also imagine that there will be times where we'll need to call GetPageView again.

Any feedback would be greatly apricated.

Regards

Simon Nordahl / NORRIQ.

 

 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Simon

You can call getpageview with an ID of a page that exists or create a new pageview instance and call its load method (that will read the ID from querystring or fallback to the domains default website and page)

BR Nicolai

Votes for this answer: 1
 
Simon Nordahl
Simon Nordahl
Reply

Great thank you for the feedback Nicolai, it works like a charm.

I do still think you should remove the method GetPageView() since it always will default to pageid = 0 and therefore always throws an exception.

 
Nicolai Pedersen
Reply

Agreed. Will mark it for deletion!

Thanks, Nicolai

 

You must be logged in to post in the forum