1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 19:24:02 +00:00

Only grant the permissions from the static property in the user creation job

This commit is contained in:
lukinovec 2023-06-14 08:30:33 +02:00
parent 73144a874a
commit c31340bff0

View file

@ -17,6 +17,8 @@ class CreatePostgresUserForTenant implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public static array $permissions = ['ALL'];
/**
* Create a new job instance.
*
@ -57,7 +59,10 @@ class CreatePostgresUserForTenant implements ShouldQueue
foreach ($tenantModels as $model) {
$table = $model->getTable();
$databaseManager->database()->statement("GRANT ALL ON {$table} TO \"{$userName}\"");
foreach (static::$permissions as $permission) {
$databaseManager->database()->statement("GRANT {$permission} ON {$table} TO \"{$userName}\"");
}
$databaseManager->database()->statement("GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO \"{$userName}\"");
}
});