diff --git a/app/mongo/lib/mongo_adaptor_server.rb b/app/mongo/lib/mongo_adaptor_server.rb index a82d78f..0959f00 100644 --- a/app/mongo/lib/mongo_adaptor_server.rb +++ b/app/mongo/lib/mongo_adaptor_server.rb @@ -37,7 +37,11 @@ def db @mongo_db ||= ::Mongo::MongoClient.from_uri(Volt.config.db_uri) @db ||= @mongo_db.db(Volt.config.db_uri.split('/').last || Volt.config.db_name) else - @mongo_db ||= ::Mongo::MongoClient.new(Volt.config.db_host, Volt.config.db_port) + options = {} + options[:user] = Volt.config.db_user if Volt.config.db_user.present? + options[:password] = Volt.config.db_password if Volt.config.db_password.present? + + @mongo_db ||= ::Mongo::MongoClient.new(Volt.config.db_host, Volt.config.db_port, options) @db ||= @mongo_db.db(Volt.config.db_name) end