NetTalk Central

Author Topic: Login Example (3) - how to redirect to a page based on security level  (Read 3974 times)

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
I'm using as the basis for my web app, the Basic login example.

I wanted to collect the User ID and password, then get the user from the User table, and based on their security level, give them either an administrators page, or a page to view records.

I tried to set the 'URL on save' based on the security level, but realized after about 4 hours of trying to trick the system into sending the user to the right URL, that the 'URL  on save' is already set before the form is even validated.

Anyone have any simple recommendations on how to do redirect the user to the right page. If it's too complex, maybe a conditional URL on save could be added to the template.
Mike Grigsby
Credify Systems
Central Oregon, USA

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Login Example (3) - how to redirect to a page based on security level
« Reply #1 on: December 13, 2007, 07:27:00 PM »
Well, I figured out a way to do it, but it wasn't easy for this novice.

Using Philippe's example with javascript as the basis (http://www.nettalkcentral.com/index.php?option=com_smf&Itemid=36&topic=240.msg828#new)

... I simply used what he had, but instead of adding code to the "body" routine, I left it blank so it gets generated. Then, before the part where that routine's code is generated, I did a simple case statement:

CASE p_web.GetSessionValue('LLVL')
  OF 1
    packet = clip(packet) & |
      '<<body onload="load1()" ><13,10>'&|
      '<</body><13,10>'&|
      ''
  OF 2
    packet = clip(packet) & |
      '<<body onload="load2()" ><13,10>'&|
      '<</body><13,10>'&|
      ''
END !Case

Then, as you can imagine, I simply added two functions instead of the one:

<script type="text/javascript">
function load1()
{
  window.location="ListRequisitions"
}
function load2()
{
  window.location="HomePage"
}
</script>

The reason I was doing it this way is because I was not finding the SetCookie stuff to be persistent for some reason, so I used session values instead. It would be nice to have this in a template though.
Mike Grigsby
Credify Systems
Central Oregon, USA

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: Login Example (3) - how to redirect to a page based on security level
« Reply #2 on: December 15, 2007, 07:36:15 AM »
Mike ,

Have you looked at controlling access to pages via a condition in a menu?

I have a site where the customer needed different employees to have access to different features. I found the easiest way for me to do this was use a condition in a menu to allow access to differnet pages such as "accesslevel > 1 AND clienttype = owner" . this gave access to the dealership owner so he could admin orders while restricting others to mostly a read only capability.

Just a thought,

Regards,

Gregg Matteson
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'

Mike Grigsby

  • Sr. Member
  • ****
  • Posts: 380
    • Yahoo Instant Messenger - onthedotsoftware
    • View Profile
    • MyHomeAssets! Software (among others)
Re: Login Example (3) - how to redirect to a page based on security level
« Reply #3 on: December 15, 2007, 08:39:01 AM »
I do limit menu choices for various users. The problem I was encountering was the landing page after the employee has logged in though. For example, if they log in and the landing page requires a certain access level that the user doesn't require, I'm not sure what he result would be... the cancel page? I hadn't tried that, but I'm not sure it would work.
Mike Grigsby
Credify Systems
Central Oregon, USA

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: Login Example (3) - how to redirect to a page based on security level
« Reply #4 on: December 15, 2007, 08:46:39 AM »
If the landing page has a menu with the appropriate menu items exposed doesn't that take care of itself?

Regards,

Gregg Matteson
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: Login Example (3) - how to redirect to a page based on security level
« Reply #5 on: December 15, 2007, 09:03:18 AM »
Mike,

If you want to see an example of what I'm talking about email me.

glmcps at comcast dot net
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'