impersonate user

impersonate user

Postby ghasembaghi » Mon May 08, 2017 2:18 am

when an admin or parent user log in to his panel, in user list can see an option to impersonate child user.
when impersonate by a username, he can check privilege and user interface of child user, after impersonate, in header parent user can a message like this:
you loged in as 'David', to back to admin(parent) click here
ghasembaghi
 
Posts: 196
Joined: Sat Dec 01, 2012 6:49 pm

Re: impersonate user

Postby andyrav » Mon May 08, 2017 2:06 pm

+1
andyrav
 
Posts: 315
Joined: Wed Feb 25, 2015 6:38 pm

Re: impersonate user

Postby wernerbooysen » Thu May 11, 2017 8:52 pm

Yes - please!
wernerbooysen
 
Posts: 1
Joined: Thu May 11, 2017 8:51 pm

Re: impersonate user

Postby Adam » Sun May 14, 2017 12:32 am

This can be done quite easily already - we implemented it in some projects since v9.2

Just use jQuery to place a button somewhere sensible and reload the page with a 'switch' or 'switchback' query parameter.

In the page header, add a small section of code that copies and replaces / reverts the relevant $_SESSION[] values.

It works very well - doesn't even log out users, so it's a great for support / admin / management staff to quickly log in as a client user and see what they see :-)
Adam
 
Posts: 109
Joined: Wed Jan 09, 2013 7:53 pm

Re: impersonate user

Postby andyrav » Sun May 14, 2017 3:46 pm

hi
could you post your code please?
andyrav
 
Posts: 315
Joined: Wed Feb 25, 2015 6:38 pm

Re: impersonate user

Postby Adam » Mon May 15, 2017 2:52 pm

Put something like this in the head:

// switch from admin/staff to a regular profile
if (CurrentUserLevel() != 1 && isset($_GET['SetProfile'])) {
$_SESSION['_ROOT_PROFILE'] = array(
'SysAdmin' => $_SESSION['YourProject_SysAdmin'],
'Level' => $_SESSION['YourProject_status_UserLevel'],
'ID' => $_SESSION['YourProject_status_UserName']
);
$_SESSION['YourProject_SysAdmin'] = 0;
$_SESSION['YourProject_status_UserLevel'] = 0;
unset($_SESSION['YourProject_status_UserLevelValue']);
$_SESSION['YourProject_status_UserName'] = (int) $_GET['SetProfile'];
$_SESSION['YourProject_status_UserProfile_UserName'] = (int) $_GET['SetProfile'];
header("Location: your_default_page.php");
exit;
}
// resume to admin/staff from a regular profile
else if (CurrentUserLevel() == 0 && isset($_GET['ResumeRootProfile']) && isset($_SESSION['_ROOT_PROFILE'])) {
$_SESSION['YourProject_SysAdmin'] = $_SESSION['_ROOT_PROFILE']['SysAdmin'];
$_SESSION['YourProject_status_UserLevel'] = $_SESSION['_ROOT_PROFILE']['Level'];
$_SESSION['YourProject_status_UserName'] = $_SESSION['_ROOT_PROFILE']['ID'];
$_SESSION['YourProject_status_UserProfile_UserName'] = $_SESSION['_ROOT_PROFILE']['ID'];
unset($_SESSION['_ROOT_PROFILE']);
header("Location: your_default_page.php");
exit;
}

...and then put some jQuery in the footer to display a 'switch' / 'switch back' button.

The most sensible places for buttons would be in each row of the users List/Grid page and on the View page.

It's pretty simple to implement and really makes life easier for staff :)
Adam
 
Posts: 109
Joined: Wed Jan 09, 2013 7:53 pm

Re: impersonate user

Postby horizon_iet » Tue Jun 27, 2017 8:55 pm

+1!
horizon_iet
 
Posts: 1
Joined: Tue Jun 27, 2017 8:53 pm

Re: impersonate user

Postby keithh0427 » Mon Jul 17, 2017 8:52 am

+1
keithh0427
 
Posts: 138
Joined: Tue Nov 20, 2012 7:58 am


Return to Feature Requests (PHPMaker)