Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove user parameter from getGate method #99

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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