feat: Adding findLoads service per account type (driver, shipper, carrier)

This commit is contained in:
Josepablo Cruz
2026-03-31 20:28:16 -06:00
parent 4310d3a0c3
commit db6804145b
6 changed files with 637 additions and 59 deletions

View File

@@ -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' ){