1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 01:34:03 +00:00

fix: not using template/tenant hostname while creating database users

This commit is contained in:
Shaheen 2025-02-04 11:58:28 +02:00
parent 22dcb8b069
commit 439ce0e915

View file

@ -25,14 +25,14 @@ class PermissionControlledMySQLDatabaseManager extends MySQLDatabaseManager impl
$hostname = $databaseConfig->connection()['host']; $hostname = $databaseConfig->connection()['host'];
$password = $databaseConfig->getPassword(); $password = $databaseConfig->getPassword();
$this->database()->statement("CREATE USER `{$username}`@`%` IDENTIFIED BY '{$password}'"); $this->database()->statement("CREATE USER `{$username}`@`{$hostname}` IDENTIFIED BY '{$password}'");
$grants = implode(', ', static::$grants); $grants = implode(', ', static::$grants);
if ($this->isVersion8()) { // MySQL 8+ if ($this->isVersion8()) { // MySQL 8+
$grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`%`"; $grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`{$hostname}`";
} else { // MySQL 5.7 } else { // MySQL 5.7
$grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`%` IDENTIFIED BY '$password'"; $grantQuery = "GRANT $grants ON `$database`.* TO `$username`@`{$hostname}` IDENTIFIED BY '$password'";
} }
return $this->database()->statement($grantQuery); return $this->database()->statement($grantQuery);