permissions

This commit is contained in:
2023-10-17 22:57:25 +03:00
parent 4b9e9cb4f6
commit 632684f514
29 changed files with 370 additions and 223 deletions
+21 -1
View File
@@ -2,13 +2,18 @@
namespace Lucent\Account;
use Lucent\Channel\ChannelService;
use Lucent\Primitive\Collection;
use Lucent\Schema\SchemaService;
readonly class AccountService
{
public function __construct(
private UserRepo $userRepo,
private AuthService $authService,
private ChannelService $channelService,
private SchemaService $schemaService,
private UserRepo $userRepo,
)
{
@@ -37,5 +42,20 @@ readonly class AccountService
return $this->all()->map(fn($user) => $user->safe());
}
/**
* @return array<string>
*/
public function currentReadableSchemas(): array
{
$roles = $this->authService->currentUserRoles();
return $this->channelService->schemasReadableByRoles($roles);
}
public function currentWritableSchemas(): array
{
$roles = $this->authService->currentUserRoles();
return $this->channelService->schemasWritableByRoles($roles);
}
}