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.