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:
parent
22dcb8b069
commit
439ce0e915
1 changed files with 3 additions and 3 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue