Skip to content

Commit

Permalink
Merge pull request #87 from BinaryKitten/feature/gh72/impersonate_imp…
Browse files Browse the repository at this point in the history
…ersonator_params
  • Loading branch information
KABBOUCHI authored Jul 15, 2021
2 parents 1703932 + fc7f68f commit fb86ff5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ You need to add the method `canImpersonate()` to your user model:
/**
* @return bool
*/
public function canImpersonate()
public function canImpersonate($impersonated = null)
{
// For example
return $this->is_admin == 1;
Expand All @@ -108,7 +108,7 @@ Please make sure to pass instance Model or Nova Resource ``Impersonate::make($th
/**
* @return bool
*/
public function canBeImpersonated()
public function canBeImpersonated(?\Illuminate\Contracts\Auth\Authenticatable $impersonator = null)
{
// For example
return $this->can_be_impersonated == 1;
Expand Down
4 changes: 2 additions & 2 deletions src/Impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($user = null)
$this->exceptOnForms();

$authUser = auth()->user();
if (method_exists($authUser, 'canImpersonate') && ! $authUser->canImpersonate()) {
if (method_exists($authUser, 'canImpersonate') && ! $authUser->canImpersonate($user)) {
$this->component = null;

return;
Expand All @@ -38,7 +38,7 @@ public function __construct($user = null)
} else {
$user = $user instanceof Resource ? $user->resource : $user;

if (method_exists($user, 'canBeImpersonated') && ! $user->canBeImpersonated()) {
if (method_exists($user, 'canBeImpersonated') && ! $user->canBeImpersonated($authUser)) {
$this->component = null;

return;
Expand Down

0 comments on commit fb86ff5

Please sign in to comment.