Apply some ES6 goodies
This commit is contained in:
parent
868dc798b2
commit
ec24019cc0
@ -1,6 +1,4 @@
|
|||||||
'use strict';
|
const _ = require('underscore');
|
||||||
|
|
||||||
var _ = require('underscore');
|
|
||||||
|
|
||||||
function isApiKeyFound(apikey) {
|
function isApiKeyFound(apikey) {
|
||||||
return apikey.type !== null &&
|
return apikey.type !== null &&
|
||||||
@ -23,7 +21,7 @@ function UserDatabaseService(metadataBackend) {
|
|||||||
* @param {String} cdbUsername
|
* @param {String} cdbUsername
|
||||||
* @param {Function} callback (err, dbParams, authDbParams)
|
* @param {Function} callback (err, dbParams, authDbParams)
|
||||||
*/
|
*/
|
||||||
UserDatabaseService.prototype.getConnectionParams = function (cdbUsername, apikeyToken, isAuthenticated, callback) {
|
UserDatabaseService.prototype.getConnectionParams = function (cdbUsername, apikeyToken, authenticated, callback) {
|
||||||
this.metadataBackend.getAllUserDBParams(cdbUsername, (err, dbParams) => {
|
this.metadataBackend.getAllUserDBParams(cdbUsername, (err, dbParams) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.http_status = 404;
|
err.http_status = 404;
|
||||||
@ -41,8 +39,8 @@ UserDatabaseService.prototype.getConnectionParams = function (cdbUsername, apike
|
|||||||
dbopts.dbname = dbParams.dbname;
|
dbopts.dbname = dbParams.dbname;
|
||||||
dbopts.user = (!!dbParams.dbpublicuser) ? dbParams.dbpublicuser : global.settings.db_pubuser;
|
dbopts.user = (!!dbParams.dbpublicuser) ? dbParams.dbpublicuser : global.settings.db_pubuser;
|
||||||
|
|
||||||
var user = _.template(global.settings.db_user, {user_id: dbParams.dbuser});
|
const user = _.template(global.settings.db_user, {user_id: dbParams.dbuser});
|
||||||
var pass = null;
|
let pass = null;
|
||||||
|
|
||||||
if (global.settings.hasOwnProperty('db_user_pass')) {
|
if (global.settings.hasOwnProperty('db_user_pass')) {
|
||||||
pass = _.template(global.settings.db_user_pass, {
|
pass = _.template(global.settings.db_user_pass, {
|
||||||
@ -51,7 +49,7 @@ UserDatabaseService.prototype.getConnectionParams = function (cdbUsername, apike
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAuthenticated) {
|
if (authenticated) {
|
||||||
dbopts.user = user;
|
dbopts.user = user;
|
||||||
dbopts.pass = pass;
|
dbopts.pass = pass;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user