Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3611 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Any suggestions for logging in and it redirecting you to either the user page or the admin page based on your privilege.

 

e.g. "user" privilege redirects to "user.php", "admin" privilege redirects to "admin.php"

Posted

If you are talking about going to a particular layout, use a script triggered on OnFirstWindowOpen:

Set Variable[$pr; Value:Get(CurrentPrivilegeSetName)]
If [$pr = "user"]
   Go to Layout ["User"]
Else if [$pr = "admin"]
   Go to Layout ["Admin"]
End if

If you really mean php, then you would have to set a global field to the privilege set name, and then have the PHP API pull that field and go to the proper php page based on the result.

Posted

Maybe I wasn't clear.

 

 

If you really mean php, then you would have to set a global field to the privilege set name, and then have the PHP API pull that field and go to the proper php page based on the result.

 

 

That is what I am meaning. My website would redirect based on the privilege set name (obviously based on the account they are logging in with).

Once I have pulled the privilege set name what would the php code be to redirect admin to the admin.php page and the user to the user.php.

 

This comes from having a webpage and successfully logging in and pulling records. That I can do.

If I created for example an admin only area I don't know how to limit to stop the 'user' type getting to it so my thought would be to simply start at the login and technically build two websites. One for the admin side and the other for the user.

Posted

You will need a global calculation field in your database for PrivSetName  = Get(CurrentPrivilegeSetName). For efficiency, put it on a dedicated layout php.Priv with no other fields.  

 

Create a php script that is the action target of your login form.  In general terms it should have the form

<?php
session_start();
/*
    it may be necessary to define $_SESSION[]
    variables if your admin or user pages
    require $_POST[] information
*/
$username = $_POST["user"];
$pw = $_POST["password"];
/*
    insert database access code here
    If error, return to login page with
    header('location:loginPage.html')
*/
$get = $fm->newFindAnyCommand('php.Priv');
$exec = $get->execute();
$priv = $exec->getField('PrivSetName');
If($priv = "admin"){
    header('location:YourAdminPage.php');
}
If($priv = "user"){
    header('location:YourUserPage.php');
}
?>

Note that this script does not generate any HTML.  It just redirects to a page that does. It also needs lots of error trapping.

 

This topic is 3611 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.