Bugfix: user is not allowed

The created user don't has permission to connect to database. I changed the code to give permission

Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
Vitor Mattos 2019-04-21 14:50:31 -03:00
parent 49829482c8
commit 824cc0af1e
1 changed files with 2 additions and 0 deletions

View File

@ -154,6 +154,8 @@ class PostgreSQL extends AbstractDatabase {
// create the user
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
$query->execute();
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . $this->dbName . ' TO '.addslashes($this->dbUser));
$query->execute();
} catch (DatabaseException $e) {
$this->logger->error('Error while trying to create database user');
$this->logger->logException($e);