Skip to content

Commit 5a386ac

Browse files
committed
fixes #50
1 parent 5b44194 commit 5a386ac

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

config/nova-impersonate.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@
3535
*/
3636
'leave' => 'auth',
3737
],
38+
/**
39+
* Leave impersonate before impersonating a user
40+
*/
41+
'leave_before_impersonate' => false,
3842
];

src/Http/Controllers/ImpersonateController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public function take(Request $request, $id)
3939
$this->recordAction($request->user()->getKey(), $user_to_impersonate, 'Impersonate');
4040
}
4141

42+
if (config('nova-impersonate.leave_before_impersonate') && $this->manager->isImpersonating()) {
43+
if (config('nova-impersonate.actionable')) {
44+
$this->recordAction($this->manager->getImpersonatorId(), auth()->user(), 'Leave Impersonation');
45+
}
46+
47+
$this->manager->leave();
48+
}
49+
4250
$this->manager->take($request->user(), $user_to_impersonate);
4351

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

0 commit comments

Comments
 (0)