modifications

main
josh 3 years ago
parent b8f74a685f
commit 31b755e904

@ -31,9 +31,9 @@ facebook:
callbackURL: 'https://myfin.api.teorainfotech.com/api/v1/auth/facebook/redirect'
mail:
fromMail: 'website.tscb@gmail.com'
user: 'website.tscb@gmail.com'
pass: 'zubhybaneozurlvy'
fromMail: 'tender.tscb178@gmail.com'
user: 'tender.tscb178@gmail.com'
pass: 'gsccukdorvjyfrxr'
cron:
scheduler: false
@ -50,7 +50,7 @@ smsPhoneNumberArgName:
message: 'text'
url:
url: "http://localhost:4200/#"
url: "https://tender.accuratesoftware.online/#"
bodyWay2SMS:
apikey: "CKDG9HL5KYFLLILRMX3QX1CPKOIP8QF1"

@ -1,7 +1,7 @@
import { Controller, Get, UseGuards, Res, Req, Body, ValidationPipe, Post, HttpCode, Ip, HostParam, HttpStatus, Put, Param, Patch } from '@nestjs/common';
import { TokenDto } from './dto/token.dto';
//import { AuthGuard } from '@nestjs/passport';
import * as config from 'config';
import { AuthCreadentialsDto } from './dto/auth-credentials.dto';
import { AuthService } from './auth.service';
@ -21,16 +21,15 @@ export class AuthController {
) { }
@Post('/user-info')
async userInfo(@Body() authCredentialDto:AuthCreadentialsDto){
async userInfo(@Body() authCredentialDto: AuthCreadentialsDto) {
return this.authService.userInfo(authCredentialDto)
}
@Post('/signin')
async signIn(@Body(ValidationPipe)
authCredentialDto: AuthCreadentialsDto,
@Req() req): Promise<TokenDto> {
@Req() req): Promise<TokenDto> {
return this.authService.signIn(authCredentialDto, req.ip);
}
@ -58,17 +57,17 @@ export class AuthController {
@Post('/forgot-password')
async forgotPassword(
@Body() body: { pass: string, email: string ,otp:string },
@Body() body: { pass: string, email: string, otp: string },
): Promise<any> {
return await this.authService.forgotPassword(body);
}
@Post('/otp/:flag')
async sendOtp(
@Body() body: { email: string},
@Body() body: { email: string, custName: string, tenderName: string, bidOpenDate: string },
@Param('flag') flag: string
): Promise<void> {
return await this.authService.sendOtp(body, flag );
return await this.authService.sendOtp(body, flag);
}
// @Post('/resend-otp/:flag')

@ -43,7 +43,7 @@ export class AuthService {
private jwtService: JwtService,
private crypto: CryptoService,
private pcdotpRepository: PcdotpRepository,
private mailService : EmailService
private mailService: EmailService
) {
@ -53,15 +53,15 @@ export class AuthService {
return await this.pcduserRepository.find();
}
async userInfo(authCredentialsDto: AuthCreadentialsDto){
const { username ,secuLevel } = authCredentialsDto;
async userInfo(authCredentialsDto: AuthCreadentialsDto) {
const { username, secuLevel } = authCredentialsDto;
let user = await this.pcduserRepository.findOne({ email: (username.trim()).toLocaleLowerCase() });
if(!user){
if (!user) {
throw new BadRequestException('User Details not found')
}
if(user){
// authCredentialsDto.secuLevel = user.secuLevel
return {username:user.userName ,secuLevel:user.secuLevel , userId:user.userId , mobile:user.mobileNumber , email:user.email}
if (user) {
// authCredentialsDto.secuLevel = user.secuLevel
return { username: user.userName, secuLevel: user.secuLevel, userId: user.userId, mobile: user.mobileNumber, email: user.email }
}
@ -80,7 +80,7 @@ export class AuthService {
async validateUserPassword(authCredentialsDto: AuthCreadentialsDto): Promise<Pcduser> {
const { username, password} = authCredentialsDto;
const { username, password } = authCredentialsDto;
let user = await this.pcduserRepository.findOne({ email: (username.trim()).toLocaleLowerCase() });
console.log("user=============", user);
@ -97,123 +97,309 @@ export class AuthService {
}
}
async forgotPassword(body: { pass: string, email: string, otp:string }): Promise<any> {
async forgotPassword(body: { pass: string, email: string, otp: string }): Promise<any> {
let iuserData: PcduserDto = await this.pcduserRepository.findOne({ where: { email: body.email } });
console.log("iuserdata",iuserData);
console.log("iuserdata", iuserData);
const filter: FindManyOptions = { where: { "refCode": body.email, "status": "I" }, order: { code: "DESC" } };
const newOtp = await this.pcdotpRepository.find(filter);
const newOtp = await this.pcdotpRepository.find(filter);
if(body.otp != newOtp[0].otp){
throw new UnauthorizedException('Unauthorized Access')
}
console.log("salt1234");
const salt = await bcrypt.genSalt();
iuserData.salt = salt;
iuserData.pass = await bcrypt.hash(body.pass, salt);
console.log("salt",iuserData.salt);
console.log("pass",iuserData.pass);
try {
await this.pcduserRepository.save(iuserData);
}
catch (err) {
throw new BadRequestException("Error in Password Reset");
}
if (body.otp != newOtp[0].otp) {
throw new UnauthorizedException('Unauthorized Access')
}
console.log("salt1234");
const salt = await bcrypt.genSalt();
iuserData.salt = salt;
iuserData.pass = await bcrypt.hash(body.pass, salt);
console.log("salt", iuserData.salt);
console.log("pass", iuserData.pass);
try {
await this.pcduserRepository.save(iuserData);
}
catch (err) {
throw new BadRequestException("Error in Password Reset");
}
}
async sendMail(email: string, data: string, flag: string) {
let content: string;
let subject: string = "Login Credentials";
if (flag == 'otp') {
content = `Your one time password(OTP) for Tender Registration is, ${data} `;
subject = 'OTP'
async sendMail(email: string, custName: string, tenderName: string, bidOpenDate: string, data: string, flag: string) {
let content: string;
let subject: string = "Login Credentials";
if (flag == 'otp') {
content = `
<!doctype html>
<html lang="en-US">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>OTP</title>
<meta name="description" content="New Account Email Template.">
<style type="text/css">
a:hover {text-decoration: underline !important;}
</style>
</head>
<body marginheight="0" topmargin="0" marginwidth="0" style="margin: 0px; background-color: #f2f3f8;" leftmargin="0">
<!-- 100% body table -->
<table cellspacing="0" border="0" cellpadding="0" width="100%" bgcolor="#f2f3f8"
style="@import url(https://fonts.googleapis.com/css?family=Rubik:300,400,500,700|Open+Sans:300,400,600,700); font-family: 'Open Sans', sans-serif;">
<tr>
<td>
<table style="background-color: #f2f3f8; max-width:800px; margin:0 auto;" width="100%" border="0"
align="center" cellpadding="0" cellspacing="0">
<tr>
<td style="height:80px;">&nbsp;</td>
</tr>
<tr>
<td style="text-align:center;">
<a href="https://www.thrickodithanamscb.in/" title="logo" target="_blank">
<img width="60" src="https://www.thrickodithanamscb.in/assets/img/emblemwithoutbg.png" title="logo" alt="logo">
</a>
<h3 style="font-family: "Lucida Console", "Courier New", monospace;">THRICKODITHANAM SCB</h3>
</td>
</tr>
<tr>
<td style="height:20px;">&nbsp;</td>
</tr>
<tr>
<td>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"
style="max-width:670px; background:#fff; border-radius:3px; text-align:center;-webkit-box-shadow:0 6px 18px 0 rgba(0,0,0,.06);-moz-box-shadow:0 6px 18px 0 rgba(0,0,0,.06);box-shadow:0 6px 18px 0 rgba(0,0,0,.06);">
<tr>
<td style="height:40px;">&nbsp;</td>
</tr>
<tr>
<td style="padding:0 35px;">
<h1 style="color:#1e1e2d; font-weight:500; margin:0;font-size:32px;font-family:'Rubik',sans-serif;">OTP
</h1>
<p style="font-size:15px; color:#455056; margin:8px 0 0; line-height:24px;">
Please Register immediately after getting OTP , <br>
<strong>Your one time password(OTP) for register in tenders is</strong>.</p>
<span
style="display:inline-block; vertical-align:middle; margin:29px 0 26px; border-bottom:1px solid #cecece; width:100px;"></span>
<p
style="color:#455056; font-size:18px;line-height:20px; margin:0; font-weight: 500;">
<strong
style="display: block; font-size: 13px; margin: 24px 0 4px 0; font-weight:normal; color:rgba(0,0,0,.64);">OTP</strong>
<h1 style="font-family: "Lucida Console", "Courier New", monospace;"> ${data}</h1>
</p>
</td>
</tr>
<tr>
<td style="height:40px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height:20px;">&nbsp;</td>
</tr>
<tr>
<td style="text-align:center;">
<p style="font-size:14px; color:rgba(69, 80, 86, 0.7411764705882353); line-height:18px; margin:0 0 0;">&copy;<strong> <a href="https://www.thrickodithanamscb.in/" >www.thrickodithanamscb.in</a></strong> </p>
</td>
</tr>
<tr>
<td style="height:80px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
<!--/100% body table-->
</body>
</html> `;
subject = 'OTP'
}
}
if (flag == 'uDocSub') {
content = `Dear ${custName},<br><br>
We hope this email finds you well. We would like to express our sincere gratitude for your participation in the tender process for <a style="color:red;">${tenderName}</a>. We are pleased to inform you that your tender documents have been successfully submitted. Thank you for your meticulous efforts in preparing and submitting all the necessary documents within the specified timeframe.<br><br>
The bid opening for the tender you have participated in is scheduled for <a style="color:red;">${bidOpenDate}</a>. During this process, all submitted tenders will be carefully reviewed and assessed. We will diligently consider each proposal and evaluate it against the criteria outlined in the tender documentation.<br>
Should any additional information or documents be required, we will promptly reach out to you via the contact details provided during the submission process.<br><br>
Should you have any queries or require any clarification regarding the tender process or your submission, please contact our dedicated tender support team. You can reach us via email at tscb178@gmail.com or by calling our helpline at tel:04812441062 or tel:04812443452.<br><br>
Once again, we extend our heartfelt appreciation for your participation in this tender. Your interest and contribution are highly valued, and we look forward to the possibility of working together in the future.<br><br>
Best regards,<br>
Thrickodithanam Service Co-operative Bank LTD No 178,<br>
Kunnumpuram, Thrickodithanam,<br> Kottayam, Kerala, 686105.`;
subject = 'Tender Submission Successful - Thank you for your participation!'
}
if (flag == 'fpwd') {
content = `Your one time password(OTP) for Password reset is, ${data}`;
subject = 'OTP'
}
if (flag == 'fpwd') {
content = ` <!doctype html>
<html lang="en-US">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>OTP</title>
<meta name="description" content="New Account Email Template.">
<style type="text/css">
a:hover {text-decoration: underline !important;}
</style>
</head>
<body marginheight="0" topmargin="0" marginwidth="0" style="margin: 0px; background-color: #f2f3f8;" leftmargin="0">
<!-- 100% body table -->
<table cellspacing="0" border="0" cellpadding="0" width="100%" bgcolor="#f2f3f8"
style="@import url(https://fonts.googleapis.com/css?family=Rubik:300,400,500,700|Open+Sans:300,400,600,700); font-family: 'Open Sans', sans-serif;">
<tr>
<td>
<table style="background-color: #f2f3f8; max-width:670px; margin:0 auto;" width="100%" border="0"
align="center" cellpadding="0" cellspacing="0">
<tr>
<td style="height:80px;">&nbsp;</td>
</tr>
<tr>
<td style="text-align:center;">
<a href="https://www.thrickodithanamscb.in/" title="logo" target="_blank">
<img width="60" src="https://www.thrickodithanamscb.in/assets/img/emblemwithoutbg.png" title="logo" alt="logo">
</a>
<h3 style="font-family: "Lucida Console", "Courier New", monospace;">THRICKODITHANAM SCB</h3>
</td>
</tr>
<tr>
<td style="height:20px;">&nbsp;</td>
</tr>
<tr>
<td>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0"
style="max-width:670px; background:#fff; border-radius:3px; text-align:center;-webkit-box-shadow:0 6px 18px 0 rgba(0,0,0,.06);-moz-box-shadow:0 6px 18px 0 rgba(0,0,0,.06);box-shadow:0 6px 18px 0 rgba(0,0,0,.06);">
<tr>
<td style="height:40px;">&nbsp;</td>
</tr>
<tr>
<td style="padding:0 35px;">
<h1 style="color:#1e1e2d; font-weight:500; margin:0;font-size:32px;font-family:'Rubik',sans-serif;">OTP
</h1>
<p style="font-size:15px; color:#455056; margin:8px 0 0; line-height:24px;">
Please Register immediately after getting OTP , <br>
<strong>Your one time password(OTP) for Reset Password is</strong>.</p>
<span
style="display:inline-block; vertical-align:middle; margin:29px 0 26px; border-bottom:1px solid #cecece; width:100px;"></span>
<p
style="color:#455056; font-size:18px;line-height:20px; margin:0; font-weight: 500;">
<strong
style="display: block; font-size: 13px; margin: 24px 0 4px 0; font-weight:normal; color:rgba(0,0,0,.64);">OTP</strong>
<h1 style="font-family: "Lucida Console", "Courier New", monospace;"> ${data}</h1>
</p>
</td>
</tr>
<tr>
<td style="height:40px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height:20px;">&nbsp;</td>
</tr>
<tr>
<td style="text-align:center;">
<p style="font-size:14px; color:rgba(69, 80, 86, 0.7411764705882353); line-height:18px; margin:0 0 0;">&copy;
<strong> <a href="https://www.thrickodithanamscb.in/" >www.thrickodithanamscb.in</a></strong> </p>
</td>
</tr>
<tr>
<td style="height:80px;">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
<!--/100% body table-->
</body>
</html> `;
subject = 'OTP'
}
await this.mailService.sendMail(email, subject, content, content);
await this.mailService.sendMail(email, subject, content, content);
}
}
async sendOtp(body: { email: string}, flag: string): Promise<void> {
async sendOtp(body: { email: string, custName: string, tenderName: string, bidOpenDate: string }, flag: string): Promise<void> {
if (body.email) {
if (flag == 'F' || flag == 'R'){
if (flag == 'F' || flag == 'R' || flag == 'UD') {
let isUserExist = await this.pcduserRepository.findOne({ where: { email: body.email } });
console.log("isUserExist",isUserExist);
console.log("isUserExist", isUserExist);
if(!isUserExist && flag == "F"){
if (!isUserExist && flag == "F") {
throw new BadRequestException("User not found");
}
if (flag == 'R' && isUserExist) {
throw new BadRequestException("Already registered with this email Id.");
}else{
let newOtp = await this.generateOtp(body.email, flag);
if (body.email && flag == 'R') {
await this.sendMail(body.email, newOtp, 'otp');
}
if (body.email && flag == 'F') {
await this.sendMail(body.email, newOtp, 'fpwd');
}
}
} err => {
console.log(err,"hello12345");
};
} else {
let newOtp = await this.generateOtp(body.email, flag);
if (body.email && flag == 'R') {
await this.sendMail(body.email, body.custName, body.tenderName, body.bidOpenDate, newOtp, 'otp');
}
if (body.email && flag == 'F') {
await this.sendMail(body.email, body.custName, body.tenderName, body.bidOpenDate, newOtp, 'fpwd');
}
if (body.email && flag == 'UD') {
await this.sendMail(body.email, body.custName, body.tenderName, body.bidOpenDate, newOtp, 'uDocSub');
}
}
}
} err => {
console.log(err, "hello12345");
async tempSignUp(pcdUserDto: PcduserDto): Promise<any> {
const filter: FindManyOptions = { where: { "refCode": pcdUserDto.email, "status": "I" }, order: { code: "DESC" } };
const newOtp = await this.pcdotpRepository.find(filter);
const existingUser = await this.pcduserRepository.findOne({ where: { email: pcdUserDto.email } });
if (existingUser) {
throw new BadRequestException('User Already Exists');
}
if (pcdUserDto.otp != newOtp[0].otp) {
throw new UnauthorizedException('Unauthorized Access');
}
};
//Creating Random User_Id for every user registered
const lastUser: PcduserDto = await this.pcduserRepository.findOne({
where: {},
order: { userId: 'DESC' },
});
let maxCode = 10000;
if (lastUser && lastUser.userId) {
const lastUserId = parseInt(lastUser.userId);
maxCode = Math.max(maxCode, lastUserId);
}
const newUserId = String(maxCode + 1).padStart(5, '0');
/////////////////////////////////////////////////////////////
}
}
pcdUserDto.userId = newUserId;
const salt = await bcrypt.genSalt();
pcdUserDto.salt = salt;
pcdUserDto.pass = await bcrypt.hash(pcdUserDto.pass, salt);
pcdUserDto.secuLevel = 'U';
delete pcdUserDto['otp'];
await this.pcduserRepository.save(pcdUserDto);
this.logger.verbose("User created with email:", pcdUserDto.email);
return { data: "Successfully Registered" };
}
async tempSignUp(pcdUserDto: PcduserDto): Promise<any> {
const filter: FindManyOptions = { where: { "refCode": pcdUserDto.email, "status": "I" }, order: { code: "DESC" } };
const newOtp = await this.pcdotpRepository.find(filter);
const existingUser = await this.pcduserRepository.findOne({ where: { email: pcdUserDto.email } });
if (existingUser) {
throw new BadRequestException('User Already Exists');
}
if (pcdUserDto.otp != newOtp[0].otp) {
throw new UnauthorizedException('Unauthorized Access');
}
//Creating Random User_Id for every user registered
const lastUser: PcduserDto = await this.pcduserRepository.findOne({
where: {},
order: { userId: 'DESC' },
});
let maxCode = 10000;
if (lastUser && lastUser.userId) {
const lastUserId = parseInt(lastUser.userId);
maxCode = Math.max(maxCode, lastUserId);
}
const newUserId = String(maxCode + 1).padStart(5, '0');
/////////////////////////////////////////////////////////////
pcdUserDto.userId = newUserId;
const salt = await bcrypt.genSalt();
pcdUserDto.salt = salt;
pcdUserDto.pass = await bcrypt.hash(pcdUserDto.pass, salt);
pcdUserDto.secuLevel = 'U';
delete pcdUserDto['otp'];
await this.pcduserRepository.save(pcdUserDto);
this.logger.verbose("User created with email:", pcdUserDto.email);
return { data: "Successfully Registered" };
}
async verifyOtp(body: { otp: string, email: string }, flag: string): Promise<any> {
@ -229,7 +415,7 @@ export class AuthService {
let currentDateTime = new Date().valueOf();
let otpTime = newOtp[0].createdDate.valueOf();
let diffMs = (currentDateTime - otpTime);
let otpExpiry = 600000; //otp expire in 10 minutes
let otpExpiry = 600000; //otp expire in 10 minutes
let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000);
@ -246,7 +432,7 @@ export class AuthService {
return { data: 'success' };
}
}
}
// async resendOtp(body: { code?: string | number, email?: string, mobile: string }, flag: string): Promise<void> {
// // const newOtp = await this.generateOtp(body.code.toString(), 'RR');

@ -13,9 +13,7 @@ export class EmailService {
async sendMail(toMail:string,subject:string,bodyText: string,htmlText:string){
this.mailerService.sendMail({
to: toMail, // sender address
from: mail.fromMail, // list of receivers
subject: subject, // Subject line
to: toMail, // sender addressject: subject, // Subject line
text: bodyText, // plaintext body
html: htmlText, // HTML body content
})

@ -13,6 +13,7 @@ import { join, extname } from 'path';
import { tenderDocRepository } from 'src/tables/tender-documents/tender-doc.repository';
import { TenderDocumentDto } from 'src/dto/tender-document.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { log } from 'console';
export function createFolders(filePath: string) {
@ -58,9 +59,8 @@ export class FileUploadController {
return cb(null, childFolder);
},
filename: (req, file, cb) => {
console.log('===here===file upload==');
const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
return cb(null, `${randomName}${extname(file.originalname)}`);
// Use the original filename instead of generating a random name
return cb(null, `${file.originalname}`);
}
})
}))
@ -68,7 +68,7 @@ export class FileUploadController {
if (!file) {
return { error: 'No file uploaded.' };
}
//To return the size of the document in kb
// To return the size of the document in kb
const fileSizeKB = Math.ceil(file.size / 1024);
return { fileName: file.filename, filePath: file.path, fileSizeKB };
}
@ -88,9 +88,8 @@ export class FileUploadController {
return cb(null, filePath);
},
filename: (req, file, cb) => {
console.log('===here===file upload==');
const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
return cb(null, `${randomName}${extname(file.originalname)}`);
// Use the original filename instead of generating a random name
return cb(null, `${file.originalname}`);
}
})
}))
@ -116,9 +115,8 @@ export class FileUploadController {
return cb(null, filePath);
},
filename: (req, file, cb) => {
console.log('===here===file upload==');
const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
return cb(null, `${randomName}${extname(file.originalname)}`);
// Use the original filename instead of generating a random name
return cb(null, `${file.originalname}`);
}
})
}))
@ -243,9 +241,8 @@ async deleteNotice(
return cb(null, filePath);
},
filename: (req, file, cb) => {
console.log('===here===file upload==');
const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
return cb(null, `${randomName}${extname(file.originalname)}`);
// Use the original filename instead of generating a random name
return cb(null, `${file.originalname}`);
}
})
}))
@ -380,7 +377,13 @@ async deleteNotice(
@Req() req,
) {
const folderPath = path.join('./uploads/Drawings', id);
console.log(folderPath);
if (!fs.existsSync(folderPath)) {
console.log(
"helloo"
);
res.status(404).send({ error: 'File not found' });
return;
}

@ -3,7 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
import { PaymentMasterDto } from 'src/dto/payment-master.dto';
import { PcdFormGridService } from 'src/framework/beans/pcd-form-grid.service';
import { PaymentMasterRepository } from './payment-master.repository';
import { log } from 'console';
@Injectable()
export class PaymentMasterService extends PcdFormGridService<PaymentMasterDto>{
@ -58,8 +58,6 @@ async finalBidAmt(tenderId ,userId,body){
}else{
throw new BadRequestException('Bid Amount Already Exist')
}
}
}

@ -15,7 +15,14 @@ export class TenderController extends PcdTransactionController<TenderDetailDto>
@Get('admin')
async getTender() {
return this.tenderService.GetAdminTenderD()
}
@Get('admin/dashboard')
async getDashboard() {
return this.tenderService.GetAdminDashboard()
}
}

@ -54,4 +54,8 @@ export class TenderService extends PcdTransactionService<TenderDetailDto>{
return this.tenderMasterRepository.find()
}
async GetAdminDashboard(){
let query = `select id, title , bid_open_date as bidOpenDate, publish_date as publishDate from tender_master tm `
return this.tenderMasterRepository.query(query)
}
}

Loading…
Cancel
Save