Authorization 3x before method pseudo type error

I am just following the Authorization 3x Documentation, and before method in User policy for Admin can view anything in dashboard but Before Method trigger error due to return Bool value… let me show first what Documentation say…

You can clearly seen if false return so it means user not Allow to proceed but if Null return then Decision goes to Authorization Method but if set Null return type it give me error because of return type must be Bool

The docs need to be updated but all you’d need to do is update your method signature to what the interface defines

so try

public function before(?\Authorization\IdentityInterface $identity, mixed $resource, string $action): \Authorization\Policy\ResultInterface|bool|null {
    // your content

1 Like

thanks @KevinPfeifer please update docs as soon as possible :laughing: sometimes its very tricky to understand what exactly wrong in code hahahah… just confusing me

Already done

Usually your IDE/Editor helps you overwriting/implementing these methods and therefore provide you with the correct types.

But I don’t know which VS Code Extension you need so it know how to properly auto-complete these methods for you instead of you having to look up docs and/or the source code.