fixed estimated fees and bind mismatch in transmit application and removed comments,logs

This commit is contained in:
Kallesh B S 2025-07-24 15:03:28 +05:30
parent 91208d950d
commit 5cebcef300
10 changed files with 41 additions and 179 deletions

View File

@ -19,6 +19,7 @@ export class AuthController {
@Post('login') @Post('login')
@HttpCode(200) @HttpCode(200)
async loginClient(@Body() body: AuthLoginDTO, @Res({ passthrough: true }) res: Response, @Req() req: Request) { async loginClient(@Body() body: AuthLoginDTO, @Res({ passthrough: true }) res: Response, @Req() req: Request) {
let k: any = await this.authService.loginUser(body.P_EMAILADDR.toLowerCase(), body.P_PASSWORD, req); let k: any = await this.authService.loginUser(body.P_EMAILADDR.toLowerCase(), body.P_PASSWORD, req);
if (k.access_token) { if (k.access_token) {

View File

@ -151,14 +151,12 @@ export class AuthService {
// Validate the response shape // Validate the response shape
if (!data?.keys || !Array.isArray(data.keys)) { if (!data?.keys || !Array.isArray(data.keys)) {
console.log("Invalid JWKS response");
throw new UnauthorizedException('Authentication failed'); throw new UnauthorizedException('Authentication failed');
} }
// Find the key with the matching kid // Find the key with the matching kid
const key = data.keys.find((k) => k.kid === kid); const key = data.keys.find((k) => k.kid === kid);
if (!key) { if (!key) {
console.log("Authentication failed: Key not found");
throw new UnauthorizedException('Authentication failed'); throw new UnauthorizedException('Authentication failed');
} }
@ -174,7 +172,6 @@ export class AuthService {
// Optionally log error details for debugging // Optionally log error details for debugging
console.error('Failed to retrieve or process JWKS:', error); console.error('Failed to retrieve or process JWKS:', error);
// Wrap other errors as InternalServerException // Wrap other errors as InternalServerException
console.log('Failed to retrieve public key');
throw new InternalServerErrorException(); throw new InternalServerErrorException();
} }
} }
@ -192,8 +189,6 @@ export class AuthService {
return { active: Array.isArray(sessionData) && sessionData.length > 0 }; return { active: Array.isArray(sessionData) && sessionData.length > 0 };
} catch (error: any) { } catch (error: any) {
console.log("Error in introspectToken:", error.message || error);
if (error instanceof UnauthorizedException) { if (error instanceof UnauthorizedException) {
throw error; throw error;
} }
@ -224,7 +219,6 @@ export class AuthService {
} catch (error) { } catch (error) {
if (error instanceof UnauthorizedException) throw error if (error instanceof UnauthorizedException) throw error
console.log("Error while getting User session.....");
throw new InternalServerErrorException() throw new InternalServerErrorException()
} }
} }
@ -243,7 +237,6 @@ export class AuthService {
const introspection = await this.introspectToken(token); const introspection = await this.introspectToken(token);
if (!introspection.active) { if (!introspection.active) {
console.log("Introspect failed for token");
throw new UnauthorizedException("Authentication Failed") throw new UnauthorizedException("Authentication Failed")
} }
@ -267,6 +260,32 @@ export class AuthService {
try { try {
const userSession = await this.getUserSession(username) const userSession = await this.getUserSession(username)
const emailVerifyResponse: any = await this.userMaintenanceService.ValidateEmail({ P_EMAILADDR: username })
if (Array.isArray(emailVerifyResponse) && emailVerifyResponse[0].ERRORMESG) {
throw new BadRequestException();
}
let ROLE = "";
if (Array.isArray(emailVerifyResponse) && !emailVerifyResponse[0].ERRORMESG) {
switch (emailVerifyResponse[0].SOURCE) {
case "USCIB": ROLE = 'ua'; break;
case "SP": ROLE = 'sa'; break;
case "CLIENT": ROLE = 'ca'; break;
}
}
// if (ROLE === 'ua' && req.headers.origin !== 'https://policy.alphaomegainfosys.com') {
// throw new BadRequestException("Invalid username or password")
// }
// else if (ROLE === 'sa' && req.headers.origin !== 'https://sp.alphaomegainfosys.com') {
// throw new BadRequestException("Invalid username or password")
// }
// else if (ROLE === 'ca' && req.headers.origin !== 'https://client.alphaomegainfosys.com') {
// throw new BadRequestException("Invalid username or password")
// }
if (access_token && refresh_token && userSession.length > 0) { if (access_token && refresh_token && userSession.length > 0) {
const getSub: any = jwt.decode(refresh_token, { complete: true }) const getSub: any = jwt.decode(refresh_token, { complete: true })
@ -292,8 +311,6 @@ export class AuthService {
return k; return k;
} catch (error) { } catch (error) {
console.log("error while logging : ", error.message);
throw new BadRequestException('Invalid username or password'); throw new BadRequestException('Invalid username or password');
} }
} }
@ -314,7 +331,6 @@ export class AuthService {
const response = await axios.request(options); const response = await axios.request(options);
if (response.status !== 200 || !Array.isArray(response.data)) { if (response.status !== 200 || !Array.isArray(response.data)) {
console.log("failed to retrieve user-id....");
throw new UnauthorizedException("Authentication failed") throw new UnauthorizedException("Authentication failed")
} }
@ -326,7 +342,6 @@ export class AuthService {
} }
} catch (error) { } catch (error) {
console.log("Error in getUserIdByEmail ...........");
if (error instanceof UnauthorizedException) { if (error instanceof UnauthorizedException) {
throw error throw error
} }
@ -353,9 +368,6 @@ export class AuthService {
return userResponse.data; return userResponse.data;
} catch (error) { } catch (error) {
console.log(error.message);
console.log("Error in getUserDetailsById ...........");
if (error instanceof UnauthorizedException) { if (error instanceof UnauthorizedException) {
throw error; throw error;
} }
@ -377,9 +389,6 @@ export class AuthService {
}); });
if (userResponse.status !== 200 || !Array.isArray(userResponse.data)) { if (userResponse.status !== 200 || !Array.isArray(userResponse.data)) {
console.log("userResponse : ", userResponse);
console.log("userResponse status : ", userResponse.status);
throw new UnauthorizedException("Authentication failed"); throw new UnauthorizedException("Authentication failed");
} }
@ -406,9 +415,6 @@ export class AuthService {
}; };
} catch (error) { } catch (error) {
console.log(error.message);
console.log("Error in getUserDetailsByEmail ...........");
if (error instanceof UnauthorizedException) { if (error instanceof UnauthorizedException) {
throw error; throw error;
} }
@ -454,9 +460,6 @@ export class AuthService {
try { try {
const { data } = await axios.request(options2); const { data } = await axios.request(options2);
console.log("forgot password status API request", data.status);
const forgotPasswordStatus = await this.updateForgotPassword(userDetails) const forgotPasswordStatus = await this.updateForgotPassword(userDetails)
if (!forgotPasswordStatus) { if (!forgotPasswordStatus) {
@ -466,8 +469,6 @@ export class AuthService {
return { statusCode: 200, message: 'password reset successfull' } return { statusCode: 200, message: 'password reset successfull' }
} catch (error) { } catch (error) {
// console.error(error); // console.error(error);
console.log(error.message);
throw new InternalServerErrorException() throw new InternalServerErrorException()
} }
@ -487,7 +488,6 @@ export class AuthService {
}); });
if (!data.access_token) { if (!data.access_token) {
console.log("failed to retrieve admin access token.....");
throw new UnauthorizedException("Authentication failed") throw new UnauthorizedException("Authentication failed")
} }
@ -495,7 +495,6 @@ export class AuthService {
} catch (error) { } catch (error) {
if (error instanceof UnauthorizedException) throw error if (error instanceof UnauthorizedException) throw error
console.log("Error in getAdminAccessToken");
throw new InternalServerErrorException(); throw new InternalServerErrorException();
} }
} }
@ -567,30 +566,20 @@ export class AuthService {
if (!ROLE) { if (!ROLE) {
console.log("ERROR while giving access : ");
throw new InternalServerErrorException(); throw new InternalServerErrorException();
} }
const res = await this.assignRoleToUser(uid, ROLE); const res = await this.assignRoleToUser(uid, ROLE);
console.log("Assigning Role sussessfully ");
console.log(res);
return { statusCode: 201, message: 'User registered successfully' }; return { statusCode: 201, message: 'User registered successfully' };
} }
} catch (error) { } catch (error) {
console.log(error.message);
if (error.message === "Request failed with status code 409") { if (error.message === "Request failed with status code 409") {
throw new ConflictException("User already exist"); throw new ConflictException("User already exist");
} }
else if (error instanceof BadRequestException) { else if (error instanceof BadRequestException) {
console.log("ERROR while registering : ", error.message);
return error; return error;
} }
console.log("ERROR while giving access : ", error.message);
throw new InternalServerErrorException('Failed to create user'); throw new InternalServerErrorException('Failed to create user');
} }
} }
@ -612,7 +601,6 @@ export class AuthService {
}); });
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
console.log(`✅ Role "${roleName}" successfully assigned to user ${userId}.`);
return { message: "Successfully assigned to user" }; return { message: "Successfully assigned to user" };
} else { } else {
console.error(`❌ Failed to assign role. Status: ${response.status}, Data:`, response.data); console.error(`❌ Failed to assign role. Status: ${response.status}, Data:`, response.data);
@ -724,9 +712,6 @@ export class AuthService {
const refreshToken = req.cookies['refresh_token']; const refreshToken = req.cookies['refresh_token'];
if (!refreshToken) { if (!refreshToken) {
console.log("refesh token not present");
throw new UnauthorizedException('Authentication failed'); throw new UnauthorizedException('Authentication failed');
} }
@ -754,7 +739,6 @@ export class AuthService {
} else { } else {
console.error('🔴 Unexpected error:', error.message); console.error('🔴 Unexpected error:', error.message);
} }
console.log("Error while refreshing tokens : ", error.message);
throw new UnauthorizedException('Authentication failed'); throw new UnauthorizedException('Authentication failed');
} }
} }
@ -783,18 +767,13 @@ export class AuthService {
else { else {
token = this.REGISTER_SIGN_JWT.sign({ email: payload.P_TO }); token = this.REGISTER_SIGN_JWT.sign({ email: payload.P_TO });
} }
console.log("Register token : ", token);
if (!token) { if (!token) {
console.log("Register Token Generation failed");
throw new InternalServerErrorException(); throw new InternalServerErrorException();
} }
return token; return token;
} }
catch (error) { catch (error) {
console.log(error.message);
throw new InternalServerErrorException("Register Token Generation failed") throw new InternalServerErrorException("Register Token Generation failed")
} }
} }
@ -826,17 +805,12 @@ export class AuthService {
const userResponse = await axios.request(options2); const userResponse = await axios.request(options2);
if (userResponse.status !== 204) { if (userResponse.status !== 204) {
console.log("Error updating forgot-password : ");
throw new InternalServerErrorException(); throw new InternalServerErrorException();
} }
return true; return true;
} catch (error) { } catch (error) {
console.log("Error updating forgot password");
console.log("Error : ", error.message);
return false; return false;
} }
} }
@ -872,7 +846,6 @@ export class AuthService {
} }
async sendMail(body: SendMailDTO) { async sendMail(body: SendMailDTO) {
console.log("mail body : ", body);
let token: string; let token: string;
let ROLE: string = ""; let ROLE: string = "";
let uuid: string | undefined = undefined; let uuid: string | undefined = undefined;
@ -905,8 +878,6 @@ export class AuthService {
try { try {
await this.mailService.sendMail({ ...mailTemplate }); await this.mailService.sendMail({ ...mailTemplate });
console.log('Email sent successfully');
if (body.P_MAIL_TYPE === MailTypeDTO.FORGOT_PASSWORD) { if (body.P_MAIL_TYPE === MailTypeDTO.FORGOT_PASSWORD) {
let forgotPasswordStatus = await this.updateForgotPassword(userDetails, uuid); let forgotPasswordStatus = await this.updateForgotPassword(userDetails, uuid);

View File

@ -90,7 +90,6 @@ export class MssqlDBService {
await this.pool.connect(); await this.pool.connect();
this.poolConnected = true; this.poolConnected = true;
console.log('Database connection pool initialized.');
} }
return this.pool; return this.pool;
} catch (error) { } catch (error) {

View File

@ -21,16 +21,11 @@ export class JwtAuthGuard implements CanActivate {
const token = request.cookies?.access_token; const token = request.cookies?.access_token;
const body = request.body; const body = request.body;
console.log("from JWT guard body : ", body);
if (body?.P_MAIL_TYPE && body?.P_MAIL_TYPE === MailTypeDTO.FORGOT_PASSWORD) { if (body?.P_MAIL_TYPE && body?.P_MAIL_TYPE === MailTypeDTO.FORGOT_PASSWORD) {
return true; return true;
} }
if (!token) { if (!token) {
console.log("No token found from Request");
throw new UnauthorizedException('Authentication failed'); throw new UnauthorizedException('Authentication failed');
} }
try { try {

View File

@ -30,8 +30,6 @@ export class RegisterGuard implements CanActivate {
request['user'] = payload; request['user'] = payload;
return true; return true;
} catch (err) { } catch (err) {
console.log("Error in register guard : ", err.message);
throw new UnauthorizedException("Invalid Register Token"); throw new UnauthorizedException("Invalid Register Token");
} }
} }

View File

@ -26,9 +26,6 @@ export class RolesGuard implements CanActivate {
const token = request.cookies?.access_token; // Token is stored as HttpOnly cookie const token = request.cookies?.access_token; // Token is stored as HttpOnly cookie
const body = request.body; const body = request.body;
console.log("from JWT guard body : ", body);
if (body?.P_MAIL_TYPE && body?.P_MAIL_TYPE === MailTypeDTO.FORGOT_PASSWORD) { if (body?.P_MAIL_TYPE && body?.P_MAIL_TYPE === MailTypeDTO.FORGOT_PASSWORD) {
return true; return true;
} }
@ -49,8 +46,6 @@ export class RolesGuard implements CanActivate {
return true; return true;
} catch (err: any) { } catch (err: any) {
console.log("from roles guard : ", err.message);
throw new UnauthorizedException('Authentication Failed'); throw new UnauthorizedException('Authentication Failed');
} }
} }

View File

@ -19,10 +19,6 @@ export class LogoutInterceptor implements NestInterceptor {
// Send a custom 200 response when refresh token is missing // Send a custom 200 response when refresh token is missing
response.clearCookie('access_token'); response.clearCookie('access_token');
response.clearCookie('refresh_token'); response.clearCookie('refresh_token');
console.log("No tokens found so logging-out");
response.status(200).json({ response.status(200).json({
statusCode: 200, statusCode: 200,
message: 'Logged-Out successfully', message: 'Logged-Out successfully',

View File

@ -57,6 +57,10 @@ export class ParamTableService {
} }
async CREATEPARAMRECORD(body: CreateParamRecordDTO) { async CREATEPARAMRECORD(body: CreateParamRecordDTO) {
console.log("rbody : ", body);
let connection: mssql.ConnectionPool; let connection: mssql.ConnectionPool;
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();

View File

@ -73,104 +73,10 @@ export class CarnetApplicationService {
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
// const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
// return res;
// const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
// if (typeof GLTABLE !== 'function') {
// throw new InternalServerException('GLTABLE is not a constructor');
// }
// async function createGLArrayInstance(
// ITEMNO,
// ITEMDESCRIPTION,
// ITEMVALUE,
// NOOFPIECES,
// ITEMWEIGHT,
// ITEMWEIGHTUOM,
// GOODSORIGINCOUNTRY,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.GLARRAY(:ITEMNO, :ITEMDESCRIPTION, :ITEMVALUE, :NOOFPIECES, :ITEMWEIGHT, :ITEMWEIGHTUOM, :GOODSORIGINCOUNTRY) FROM dual`,
// {
// ITEMNO,
// ITEMDESCRIPTION,
// ITEMVALUE,
// NOOFPIECES,
// ITEMWEIGHT,
// ITEMWEIGHTUOM,
// GOODSORIGINCOUNTRY,
// },
// );
// console.log(result.rows);
// return result.rows[0][0];
// }
// const GLTABLE_ARRAY: GLTABLE_DTO = {
// P_GLTABLE: await Promise.all(
// (finalBody.P_GLTABLE ?? []).map(async (x: GLTABLE_ROW_DTO) => {
// return await createGLArrayInstance(
// x.ITEMNO,
// x.ITEMDESCRIPTION,
// x.ITEMVALUE,
// x.NOOFPIECES,
// x.ITEMWEIGHT,
// x.ITEMWEIGHTUOM,
// x.GOODSORIGINCOUNTRY,
// );
// })
// )
// };
// const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY.P_GLTABLE ?? []);
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(finalBody); const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(finalBody);
// const COUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
// if (typeof COUNTRYTABLE !== 'function') {
// throw new Error('COUNTRYTABLE is not a constructor');
// }
// async function createCarnetCountryArrayInstance(
// P_VISISTTRANSITIND,
// COUNTRYCODE,
// NOOFTIMESENTLEAVE,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.CARNETCOUNTRYARRAY(:P_VISISTTRANSITIND, :COUNTRYCODE, :NOOFTIMESENTLEAVE) FROM dual`,
// {
// P_VISISTTRANSITIND,
// COUNTRYCODE,
// NOOFTIMESENTLEAVE,
// },
// );
// console.log(result.rows);
// return result.rows[0][0];
// }
// const COUNTRYTABLE_ARRAY: COUNTRYTABLE_DTO = {
// P_COUNTRYTABLE: await Promise.all(
// (finalBody.P_COUNTRYTABLE ?? []).map(async (x: COUNTRYTABLE_ROW_DTO) => {
// return await createCarnetCountryArrayInstance(
// x.P_VISISTTRANSITIND,
// x.COUNTRYCODE,
// x.NOOFTIMESENTLEAVE,
// );
// })
// )
// };
// const COUNTRYTABLE_INSTANCE = new COUNTRYTABLE(COUNTRYTABLE_ARRAY.P_COUNTRYTABLE ?? []);
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(finalBody); const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(finalBody);
// return { aa:GLTABLE_ARRAY, ab:COUNTRYTABLE_ARRAY, a: GLTABLE_INSTANCE, b: COUNTRYTABLE_INSTANCE }
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
CARNETAPPLICATION_PKG.SaveCarnetApplication( CARNETAPPLICATION_PKG.SaveCarnetApplication(
@ -193,7 +99,6 @@ export class CarnetApplicationService {
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_VARCHAR }, P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_VARCHAR },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }, P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER }, P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }, P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_VARCHAR }, P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER }, P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER },
@ -207,7 +112,6 @@ export class CarnetApplicationService {
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_VARCHAR }, P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_VARCHAR },
P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR }, P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
@ -248,10 +152,9 @@ export class CarnetApplicationService {
END;`, END;`,
{ {
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER }, P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
@ -715,11 +618,14 @@ export class CarnetApplicationService {
throw new InternalServerException("Incomplete data received from the database."); throw new InternalServerException("Incomplete data received from the database.");
} }
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
return fres.length > 0 ? fres[0] : [];
} catch (error) { } catch (error) {
handleError(error, CarnetApplicationService.name) handleError(error, CarnetApplicationService.name);
} finally { } finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name) await closeOracleDbConnection(connection, CarnetApplicationService.name);
} }
} }

View File

@ -40,8 +40,6 @@ export class OracleService {
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY, ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
} }
); );
console.log(result.rows);
return result.rows[0][0]; return result.rows[0][0];
} }
@ -94,7 +92,6 @@ export class OracleService {
P_VISISTTRANSITIND, COUNTRYCODE, NOOFTIMESENTLEAVE, P_VISISTTRANSITIND, COUNTRYCODE, NOOFTIMESENTLEAVE,
}, },
); );
console.log(result.rows);
return result.rows[0][0]; return result.rows[0][0];
} }