Skip to content

Commit

Permalink
[2.1] Remove user parameter from getGate method (#99)
Browse files Browse the repository at this point in the history
* Remove user parameter from getGate method
  • Loading branch information
erikgaal authored Feb 28, 2019
1 parent ef5cbf9 commit 86c2601
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ public function __construct(TypeRegistry $registry, Type $type = null)
/**
* Return a gate instance for the user.
*
* @param \Illuminate\Foundation\Auth\User|null $user
* @return \Illuminate\Contracts\Auth\Access\Gate
*/
protected function getGate(?User $user = null): Gate
protected function getGate(): Gate
{
return app(Gate::class)->forUser($user);
return app(Gate::class);
}

/**
Expand Down Expand Up @@ -509,7 +508,7 @@ public function resolveField($source, array $args, $context, ResolveInfo $info)
protected function checkPolicy($source, $args, $context, ResolveInfo $info)
{
$user = auth()->user();
$gate = $this->getGate($user);
$gate = $this->getGate();
$policy = $this->viewPolicy;
$fieldName = $info->fieldName;

Expand Down Expand Up @@ -549,7 +548,7 @@ public function checkStorePolicy($source, $fieldName, $value): bool
}

$user = auth()->user();
$gate = $this->getGate($user);
$gate = $this->getGate();

// Check if the policy method is a closure.
if (($policy instanceof \Closure || is_callable_tuple($policy)) && $policy($user, $source, $value)) {
Expand Down

0 comments on commit 86c2601

Please sign in to comment.