NetTalk Central

Author Topic: Auto Log In  (Read 2572 times)

markster

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • Email
Auto Log In
« 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

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Auto Log In
« Reply #1 on: September 08, 2014, 02:40:23 PM »
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.

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: Auto Log In
« Reply #2 on: September 09, 2014, 12:41:17 AM »
Mark,
Something like this should work:

IF CheckAutoLogIn() = FALSE
   p_web.script('location.href="IndexPage"')
else
   p_web.script('location.href="ShowAction"')
END


Peter

markster

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • Email
Re: Auto Log In
« Reply #3 on: September 09, 2014, 02:04:24 PM »
That code to call another proc from within an embed is something I've been looking for for awhile!

Thanks,

Mark

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11193
    • View Profile
Re: Auto Log In
« Reply #4 on: September 09, 2014, 10:17:24 PM »
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

markster

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • Email
Re: Auto Log In
« Reply #5 on: September 10, 2014, 11:33:10 AM »
I'd like to do the Thursday user group, but it's been a scheduling issue. I'm working on shifting things around.

Mark

markster

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • Email
Re: Auto Log In
« Reply #6 on: September 13, 2014, 12:54:46 PM »
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