NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: markster on September 08, 2014, 08:42:24 AM
-
I'm trying to do an auto login in the event that valid cookies have been stored. My default page is IndexPage and the first logged-in page is ShowAction. So I would like to be able programmatically route the first page the user sees on entering the program to either the IndexPage or ShowAction based on whether a source procedure (CheckAutoLogIn) returns true (validated login) or false (no cookies or otherwise invalid).
My thought was to use the ShowAction page as my app's DefaultPage instead of IndexPage, but not serve it if CheckAutoLogIn() returns false and load IndexPage instead. Based on the template generated code for Only Serve If on the Security tab, I inserted the following code in the beginning of ShowAction:
IF CheckAutoLogIn() = FALSE
IndexPage(p_web)
Return -1
END
Unfortunately this results in the IndexPage being displayed as text appended to the existing text (ie without refreshing the whole screen). Where am I going wrong?
Thanks,
Mark
-
Hi Mark,
you could try adding some logic to the _sendfile routine. This is a good place where when a browser asks for one page you can serve up a different page.
-
Mark,
Something like this should work:
IF CheckAutoLogIn() = FALSE
p_web.script('location.href="IndexPage"')
else
p_web.script('location.href="ShowAction"')
END
Peter
-
That code to call another proc from within an embed is something I've been looking for for awhile!
Thanks,
Mark
-
Hi Mark,
I recommend you join us on the User Group Webinar on Thursday, and ask a question along these lines. I think there's a lot of misunderstanding at the moment about what it is you are trying to do, and how you would best go about doing it.
You need to "think web" not "think windows" when evaluating this sort of approach - but I think if we have a conversation about ti you'll understand it better.
Cheers
Bruce
-
I'd like to do the Thursday user group, but it's been a scheduling issue. I'm working on shifting things around.
Mark
-
Update: here's what I finally did. In the WebHandler, at the p_web._SendFile embed, I check for any call to IndexPage (the opening page). If the call is not an internal call from my menu (for which I have added a parameter used as a flag), I assume it is a new user. If it is, I check for any cookies that indicate an autologin. If they exist and I validate them, I proceed with the autologin and then redirect the user to the page I want; otherwise I let the IndexPage call continue unchanged.
Regards,
Mark