This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

View File

@@ -6,6 +6,7 @@ const defineAspects = require('./operation').defineAspects;
const crypto = require('crypto');
const handleCallback = require('../utils').handleCallback;
const toError = require('../utils').toError;
const emitWarning = require('../utils').emitWarning;
class AddUserOperation extends CommandOperation {
constructor(db, username, password, options) {
@@ -22,12 +23,14 @@ class AddUserOperation extends CommandOperation {
const options = this.options;
// Get additional values
let roles = Array.isArray(options.roles) ? options.roles : [];
let roles = [];
if (Array.isArray(options.roles)) roles = options.roles;
if (typeof options.roles === 'string') roles = [options.roles];
// If not roles defined print deprecated message
// TODO: handle deprecation properly
if (roles.length === 0) {
console.log('Creating a user without roles is deprecated in MongoDB >= 2.6');
emitWarning('Creating a user without roles is deprecated in MongoDB >= 2.6');
}
// Check the db name and add roles if needed