mirror of
https://github.com/archtechx/tenancy.git
synced 2026-06-21 04:04:03 +00:00
Use a more specific central db check in the hardening feature
Instead of just checking the presence of the tenants table on the current connection to determine if the table is/isn't tenant, check the current database's name, and if it's the central DB name, throw the runtime exception.
This commit is contained in:
parent
48b8aac42d
commit
565bc41bf3
1 changed files with 6 additions and 2 deletions
|
|
@ -100,8 +100,12 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
|||
throw new RuntimeException('Tenant cannot use a database of another tenant.');
|
||||
}
|
||||
|
||||
// Check if the current database doesn't have the tenants table (i.e. it's not the central database)
|
||||
if (Schema::hasTable($tenant->getTable())) {
|
||||
// Check if the current database is not the central database
|
||||
$centralDbName = DB::connection(
|
||||
config('tenancy.database.central_connection', 'central')
|
||||
)->getDatabaseName();
|
||||
|
||||
if ($dbName === $centralDbName) {
|
||||
throw new RuntimeException('Tenant cannot use the central database.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue