1. authorization helper

2. change unit test to run on memory
This commit is contained in:
omair saleh
2022-09-25 03:43:07 +08:00
parent 2b2cff7b84
commit 8ab5154130
2 changed files with 18 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
<?php
/** */
use Src\Common\Domain\Exceptions\UnauthorizedUserException;
if (! function_exists('authorize')) {
/* @throws UnauthorizedUserException */
function authorize($ability, $policy, $arguments = []): bool
{
if ($policy->{$ability}(...$arguments)) {
return true;
}
throw new UnauthorizedUserException();
}
}