This topic is locked

Usr account under admin account?

2/2/2016 7:41:07 PM
PHPRunner General questions
Tandy author

Was just wondering if there is a way to have lets say a company account. Then that company can make accounts under them for there users with there own login and password? Then the main company account can go in and view there user account files?

Let say I have companies join and they make up there employee accounts or even if the employees can join under there company account.
Then I would have companies join and only they can see there own employees information and data not other companies info..
Please let me know if you have any input on this and if it can even be done with PHPRunner Pro Enterprise 8.1..
Thanks All.

James

Admin 2/4/2016

Sure, this is possible.
Users table should have the following fields: UserID, CompanyID, UserType. UserType will hold one of the following: superadmin, admin, user.
For most data tables you can use Advanced Security option "Users can see and edit their own data only" choosing CompanyID as OwnerID field.
One more thing - you will need to restrict access to Users table itself so users can only see their record, company admins can only see their company records etc.

  1. AfterSuccessfulLogin event.
    We need to save some stuff in session variables. We need to know if current user is admin or user. We also need to save CompanyID.

$_SESSION["CompanyID"] = $data["CompanyID"];

$_SESSION["UserType"] = $data["UserType"];


2. Users table, After Table Initialized event

if ($_SESSION["UserType"]=="admin") {

$query->addWhere("CompanyID=".$_SESSION["CompanyID"])

}

if ($_SESSION["UserType"]=="user") {

$query->addWhere("UserID='".$_SESSION["UserID"]."'")

}


In this code we assume that CompanyID is a numeric field and UserID (username) is a text field.

Tandy author 2/5/2016

Thank You Sergey. I will give that a try..