Skip to content

Commit

Permalink
fixes #50
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI committed May 22, 2019
1 parent 5b44194 commit 5a386ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/nova-impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@
*/
'leave' => 'auth',
],
/**
* Leave impersonate before impersonating a user
*/
'leave_before_impersonate' => false,
];
8 changes: 8 additions & 0 deletions src/Http/Controllers/ImpersonateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public function take(Request $request, $id)
$this->recordAction($request->user()->getKey(), $user_to_impersonate, 'Impersonate');
}

if (config('nova-impersonate.leave_before_impersonate') && $this->manager->isImpersonating()) {
if (config('nova-impersonate.actionable')) {
$this->recordAction($this->manager->getImpersonatorId(), auth()->user(), 'Leave Impersonation');
}

$this->manager->leave();
}

$this->manager->take($request->user(), $user_to_impersonate);

$redirectBack = config('nova-impersonate.redirect_back');
Expand Down

0 comments on commit 5a386ac

Please sign in to comment.