The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/server/startup/migrations/v029.js

87 lines
2.0 KiB

RocketChat.Migrations.add({
version: 29,
up() {
let LDAP_Url = (RocketChat.models.Settings.findOne('LDAP_Url') || {}).value;
const LDAP_TLS = (RocketChat.models.Settings.findOne('LDAP_TLS') || {}).value;
const LDAP_DN = (RocketChat.models.Settings.findOne('LDAP_DN') || {}).value;
const LDAP_Bind_Search = (RocketChat.models.Settings.findOne('LDAP_Bind_Search') || {}).value;
if (LDAP_Url && LDAP_Url.trim() !== '') {
LDAP_Url = LDAP_Url.replace(/ldaps?:\/\//i, '');
RocketChat.models.Settings.upsert({ _id: 'LDAP_Host' }, {
$set: {
value: LDAP_Url,
},
$setOnInsert: {
createdAt: new Date,
},
});
}
if (LDAP_TLS === true) {
RocketChat.models.Settings.upsert({ _id: 'LDAP_Encryption' }, {
$set: {
value: 'tls',
},
$setOnInsert: {
createdAt: new Date,
},
});
}
if (LDAP_DN && LDAP_DN.trim() !== '') {
RocketChat.models.Settings.upsert({ _id: 'LDAP_Domain_Base' }, {
$set: {
value: LDAP_DN,
},
$setOnInsert: {
createdAt: new Date,
},
});
RocketChat.models.Settings.upsert({ _id: 'LDAP_Username_Field' }, {
$set: {
value: '',
},
$setOnInsert: {
createdAt: new Date,
},
});
RocketChat.models.Settings.upsert({ _id: 'LDAP_Unique_Identifier_Field' }, {
$set: {
value: '',
},
$setOnInsert: {
createdAt: new Date,
},
});
}
if (LDAP_Bind_Search && LDAP_Bind_Search.trim() !== '') {
RocketChat.models.Settings.upsert({ _id: 'LDAP_Custom_Domain_Search' }, {
$set: {
value: LDAP_Bind_Search,
},
$setOnInsert: {
createdAt: new Date,
},
});
RocketChat.models.Settings.upsert({ _id: 'LDAP_Use_Custom_Domain_Search' }, {
$set: {
value: true,
},
$setOnInsert: {
createdAt: new Date,
},
});
}
RocketChat.models.Settings.remove({ _id: 'LDAP_Url' });
RocketChat.models.Settings.remove({ _id: 'LDAP_TLS' });
RocketChat.models.Settings.remove({ _id: 'LDAP_DN' });
RocketChat.models.Settings.remove({ _id: 'LDAP_Bind_Search' });
},
});