index.js
function (soajs, data, cb) {
        initBLModel(soajs, function (err) {
            if (err) {
                return cb(err);
            }
            driver.model.initConnection(soajs);
            let criteria = null;
            if (!(data.username || data.id)) {
                return cb(411);
            }
            if (data.username) {
                criteria = {
                    'username': data.username
                };
            }
            else {
                let id = null;
                try {
                    id = driver.model.validateId(soajs, data.id);
                    criteria = {
                        '_id': id
                    };
                }
                catch (e) {
                    return cb(411);
                }
            }
            if (!criteria)
                return cb(403);

            utilities.findRecord(soajs, driver.model, criteria, cb, function (record) {
                delete record.password;

                let groupInfo = checkUserTenantAccess(record, soajs.tenant);
                if (groupInfo && groupInfo.groups && Array.isArray(groupInfo.groups) && groupInfo.groups.length !== 0) {
                    record.groups = groupInfo.groups;
                    record.tenant = groupInfo.tenant;
                    utilities.findGroups(soajs, driver.model, record, function (record) {
                        returnUser(record);
                    });
                }
                else {
                    returnUser(record);
                }

                function returnUser(record) {
                    utilities.assureConfig(soajs, record);
                    driver.model.closeConnection(soajs);
                    return cb(null, record);
                }
            });
        });
    }
function (soajs, data, cb) {
        initBLModel(soajs, function (err) {
            if (err) {
                return cb(err);
            }
            driver.model.initConnection(soajs);
            let criteria = null;
            if (!(data.username || data.id)) {
                return cb(411);
            }
            if (data.username) {
                criteria = {
                    'username': data.username
                };
            }
            else {
                let id = null;
                try {
                    id = driver.model.validateId(soajs, data.id);
                    criteria = {
                        '_id': id
                    };
                }
                catch (e) {
                    return cb(411);
                }
            }
            if (!criteria)
                return cb(403);

            utilities.findRecord(soajs, driver.model, criteria, cb, function (record) {
                delete record.password;

                let groupInfo = checkUserTenantAccess(record, soajs.tenant);
                if (groupInfo && groupInfo.groups && Array.isArray(groupInfo.groups) && groupInfo.groups.length !== 0) {
                    record.groups = groupInfo.groups;
                    record.tenant = groupInfo.tenant;
                    utilities.findGroups(soajs, driver.model, record, function (record) {
                        returnUser(record);
                    });
                }
                else {
                    returnUser(record);
                }

                function returnUser(record) {
                    utilities.assureConfig(soajs, record);
                    driver.model.closeConnection(soajs);
                    return cb(null, record);
                }
            });
        });
    }
function ( soajs , data , cb ) { initBLModel ( soajs , function ( err ) { if ( err ) { return cb ( err ) ; } driver . model . initConnection ( soajs ) ; let criteria = null ; if ( ! ( data . username || data . id ) ) { return cb ( 411 ) ; } if ( data . username ) { criteria = { 'username' : data . username } ; } else { let id = null ; try { id = driver . model . validateId ( soajs , data . id ) ; criteria = { '_id' : id } ; } catch ( e ) { return cb ( 411 ) ; } } if ( ! criteria ) return cb ( 403 ) ; utilities . findRecord ( soajs , driver . model , criteria , cb , function ( record ) { delete record . password ; let groupInfo = checkUserTenantAccess ( record , soajs . tenant ) ; if ( groupInfo && groupInfo . groups && Array . isArray ( groupInfo . groups ) && groupInfo . groups . length !== 0 ) { record . groups = groupInfo . groups ; record . tenant = groupInfo . tenant ; utilities . findGroups ( soajs , driver . model , record , function ( record ) { returnUser ( record ) ; } ) ; } else { returnUser ( record ) ; } function returnUser ( record ) { utilities . assureConfig ( soajs , record ) ; driver . model . closeConnection ( soajs ) ; return cb ( null , record ) ; } } ) ; } ) ; }
Get logged in record from database
Get logged in record from database