feat: Adding findLoads service per account type (driver, shipper, carrier)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
'user strict';
|
||||
const { ROOT_PATH, HANDLERS_PATH, LIB_PATH } = process.env;
|
||||
const { getModel } = require( '../Models' );
|
||||
const apiConfig = require( '../../config/apiConfig.json' );
|
||||
const { GenericHandler } = require( '../Handlers/Generic.handler' );
|
||||
const { getPagination, genKey } = require( '../../lib/Misc' );
|
||||
const { getPagination, genKey, toSha256 } = require( '../../lib/Misc' );
|
||||
|
||||
const pwd_secret = apiConfig.authentication.pwdSecret;
|
||||
|
||||
const usersModel = getModel('users');
|
||||
const companiesModel = getModel('companies');
|
||||
@@ -91,7 +94,6 @@ async function findUsers( query ){
|
||||
|
||||
function clean_user_data( data , company ){
|
||||
/// Avoid modifying sensitive fields.
|
||||
if( data.password ){ delete data.password; }
|
||||
if( data.company ){ delete data.company; }
|
||||
if( data.job_role ){
|
||||
/** You can only modify the role of a user if it is in the following list */
|
||||
@@ -106,6 +108,10 @@ function clean_user_data( data , company ){
|
||||
data.job_role = "staff";
|
||||
}
|
||||
}
|
||||
if( data.password ){
|
||||
/// Generate safe password
|
||||
data.password = toSha256( data.password + pwd_secret );
|
||||
}
|
||||
if( data.permissions ){ delete data.permissions; }
|
||||
if( company ){
|
||||
if( company.company_type === 'Shipper' ){
|
||||
|
||||
Reference in New Issue
Block a user