diff --git a/README.md b/README.md index 07e2f80..95df662 100644 --- a/README.md +++ b/README.md @@ -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; @@ -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; diff --git a/src/Impersonate.php b/src/Impersonate.php index 7a8b5ad..c4cf640 100644 --- a/src/Impersonate.php +++ b/src/Impersonate.php @@ -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; @@ -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;