Skip to content

Commit e24519a

Browse files
committed
Allow anonymous connection
- If no user was given an empy user was set resulting in an error
1 parent a1ed46f commit e24519a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Jenssegers/Mongodb/Connection.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ protected function createConnection($dsn, array $config, array $options)
137137
}
138138

139139
// Check if the credentials are not already set in the options
140-
if (!isset($options['username'])) {
141-
$options['username'] = isset($config['username']) ? $config['username'] : '';
140+
if (!isset($options['username']) && isset($config['username'])) {
141+
$options['username'] = $config['username'];
142142
}
143-
if (!isset($options['password'])) {
144-
$options['password'] = isset($config['password']) ? $config['password'] : '';
143+
if (!isset($options['password']) && isset($config['password'])) {
144+
$options['password'] = $config['password'];
145145
}
146146

147147
return new Client($dsn, $options, $driverOptions);

0 commit comments

Comments
 (0)