Skip to content

Commit 8de1b36

Browse files
committed
Only grant permission when access returns true
This fixes #635 When you provide an expression inside the `access` option, it will only work as an expression when you prefix it with `@=`. When you forget to do this, it will be just a string. Previously, the code would check if the access value is trueish instead of strict true. This granted access to all fields that had mistakenly forgotten to prefix with `@=`.
1 parent 602dc87 commit 8de1b36

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Resolver/AccessResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ private function checkAccessForStrictMode(callable $accessChecker, callable $res
5151
{
5252
$promiseOrHasAccess = $this->hasAccess($accessChecker, $resolveArgs);
5353
$callback = function ($hasAccess) use ($resolveArgs, $resolveCallback) {
54-
if (!$hasAccess) {
55-
$exceptionClassName = self::isMutationRootField($resolveArgs[3]) ? UserError::class : UserWarning::class;
56-
throw new $exceptionClassName('Access denied to this field.');
54+
if (true === $hasAccess) {
55+
return \call_user_func_array($resolveCallback, $resolveArgs);
5756
}
5857

59-
return \call_user_func_array($resolveCallback, $resolveArgs);
58+
$exceptionClassName = self::isMutationRootField($resolveArgs[3]) ? UserError::class : UserWarning::class;
59+
throw new $exceptionClassName('Access denied to this field.');
6060
};
6161

6262
if ($this->isThenable($promiseOrHasAccess)) {

0 commit comments

Comments
 (0)