Implemented easy impersonation of backend users controlled by the backend.impersonate_users permission
This commit is contained in:
parent
7fc01bb9ca
commit
a1e6849a71
|
|
@ -146,6 +146,10 @@ class ServiceProvider extends ModuleServiceProvider
|
|||
'label' => 'system::lang.permissions.manage_other_administrators',
|
||||
'tab' => 'system::lang.permissions.name'
|
||||
],
|
||||
'backend.impersonate_users' => [
|
||||
'label' => 'system::lang.permissions.impersonate_users',
|
||||
'tab' => 'system::lang.permissions.name',
|
||||
],
|
||||
'backend.manage_preferences' => [
|
||||
'label' => 'system::lang.permissions.manage_preferences',
|
||||
'tab' => 'system::lang.permissions.name'
|
||||
|
|
|
|||
|
|
@ -120,7 +120,12 @@ class Auth extends Controller
|
|||
*/
|
||||
public function signout()
|
||||
{
|
||||
BackendAuth::logout();
|
||||
if (BackendAuth::isImpersonator()) {
|
||||
BackendAuth::stopImpersonate();
|
||||
} else {
|
||||
BackendAuth::logout();
|
||||
}
|
||||
|
||||
return Backend::redirect('backend');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,24 @@ class Users extends Controller
|
|||
return Redirect::refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Impersonate this user
|
||||
*/
|
||||
public function update_onImpersonateUser($recordId)
|
||||
{
|
||||
if (!$this->user->hasAccess('backend.impersonate_users')) {
|
||||
return Response::make(Lang::get('backend::lang.page.access_denied.label'), 403);
|
||||
}
|
||||
|
||||
$model = $this->formFindModelObject($recordId);
|
||||
|
||||
BackendAuth::impersonate($model);
|
||||
|
||||
Flash::success(Lang::get('backend::lang.account.impersonate_success'));
|
||||
|
||||
return Backend::redirect('backend/users/myaccount');
|
||||
}
|
||||
|
||||
/**
|
||||
* My Settings controller
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
<?php if ($this->user->hasAccess('backend.impersonate_users')): ?>
|
||||
<div class="loading-indicator-container">
|
||||
<button
|
||||
type="button"
|
||||
data-request="onImpersonateUser"
|
||||
data-load-indicator="<?= e(trans('backend::lang.account.impersonate_working')) ?>"
|
||||
data-request-confirm="<?= e(trans('backend::lang.account.impersonate_confirm')) ?>"
|
||||
class="btn btn-danger oc-icon-user-secret"
|
||||
style="width: 100%; text-align: center"
|
||||
>
|
||||
<?= e(trans('backend::lang.account.impersonate')) ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
|
@ -45,6 +45,12 @@ return [
|
|||
'not_found' => "AJAX handler ':name' was not found."
|
||||
],
|
||||
'account' => [
|
||||
'impersonate' => 'Impersonate user',
|
||||
'impersonate_confirm' => 'Are you sure you want to impersonate this user? You can revert to your original state by logging out.',
|
||||
'impersonate_success' => 'You are now impersonating this user',
|
||||
'impersonate_working' => 'Impersonating...',
|
||||
'impersonating' => 'Impersonating :full_name',
|
||||
'stop_impersonating' => 'Stop impersonating',
|
||||
'signed_in_as' => 'Signed in as :full_name',
|
||||
'sign_out' => 'Sign out',
|
||||
'login' => 'Login',
|
||||
|
|
|
|||
|
|
@ -76,7 +76,11 @@
|
|||
|
||||
<li>
|
||||
<a href="<?= Backend::url('backend/auth/signout') ?>">
|
||||
<?= e(trans('backend::lang.account.sign_out')) ?>
|
||||
<?php if (\BackendAuth::isImpersonator()) : ?>
|
||||
<?= e(trans('backend::lang.account.stop_impersonating')) ?>
|
||||
<?php else: ?>
|
||||
<?= e(trans('backend::lang.account.sign_out')) ?>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -66,6 +66,10 @@ tabs:
|
|||
|
||||
secondaryTabs:
|
||||
fields:
|
||||
btn_impersonate:
|
||||
label: ''
|
||||
context: [update]
|
||||
type: partial
|
||||
avatar:
|
||||
label: backend::lang.user.avatar
|
||||
type: fileupload
|
||||
|
|
|
|||
|
|
@ -429,6 +429,7 @@ return [
|
|||
'manage_mail_templates' => 'Manage mail templates',
|
||||
'manage_mail_settings' => 'Manage mail settings',
|
||||
'manage_other_administrators' => 'Manage other administrators',
|
||||
'impersonate_users' => 'Impersonate users',
|
||||
'manage_preferences' => 'Manage backend preferences',
|
||||
'manage_editor' => 'Manage code editor preferences',
|
||||
'view_the_dashboard' => 'View the dashboard',
|
||||
|
|
|
|||
Loading…
Reference in New Issue