update ws and fix bug
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const User = require('../models/User');
|
||||
const InstalledDevice = require('../models/GPS.InstalledDevice');
|
||||
const Withdraw = require('../models/GPS.Withdraw');
|
||||
|
||||
|
||||
module.exports.mainPage = async(req, res)=>{
|
||||
const device = await InstalledDevice.countDocuments({userId:req.user_id})
|
||||
const user = await User.findById(req.user_id).select('walletBalance dollarBalance score')
|
||||
res.status(200).json({installedDevice:device, user})
|
||||
}
|
||||
|
||||
module.exports.walletPage = async(req, res)=>{
|
||||
const withdraw = await Withdraw.findOne({userId: req.user_id, status:0})
|
||||
const user = await User.findById(req.user_id).select('walletBalance dollarBalance score')
|
||||
let pending;
|
||||
|
||||
if(withdraw){
|
||||
pending = true
|
||||
}else{
|
||||
pending = false
|
||||
}
|
||||
res.status(200).json({user, pending })
|
||||
}
|
||||
@@ -12,20 +12,26 @@ module.exports.createRequest = [
|
||||
checkValidations(validationResult),
|
||||
async (req, res) => {
|
||||
try {
|
||||
const user = await User.findById(req.user_id)
|
||||
const data = {
|
||||
card: req.body.card,
|
||||
userId: req.user_id,
|
||||
amount: user.walletBalance,
|
||||
dollarAmount: user.dollarBalance,
|
||||
status: 0
|
||||
}
|
||||
|
||||
const request = await Withdraw.create(data)
|
||||
user.dollarBalance = 0;
|
||||
user.walletBalance = 0;
|
||||
user.save()
|
||||
res.status(201).json({ msg: _sr.fa.response.success_save, data: request })
|
||||
const withdraw = await Withdraw.findOne({userId: req.user_id, status:0})
|
||||
if(withdraw){
|
||||
res.status(400).json({ msg: 'شما درخواست درحال بررسی دارید' })
|
||||
}else{
|
||||
const user = await User.findById(req.user_id)
|
||||
const data = {
|
||||
card: req.body.card,
|
||||
userId: req.user_id,
|
||||
amount: user.walletBalance,
|
||||
dollarAmount: user.dollarBalance,
|
||||
status: 0
|
||||
}
|
||||
|
||||
const request = await Withdraw.create(data)
|
||||
user.dollarBalance = 0;
|
||||
user.walletBalance = 0;
|
||||
user.save()
|
||||
res.status(201).json({ msg: _sr.fa.response.success_save, data: request })
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
res.status(500).json({ msg: error })
|
||||
|
||||
|
||||
@@ -24,7 +24,18 @@ const {
|
||||
generateRandomDigits
|
||||
} = require('../plugins/controllersHelperFunctions')
|
||||
const _faSr = _sr.fa
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: 'smtp.c1.liara.email',
|
||||
port: 587,
|
||||
secure: false, // true for 465, false for other ports
|
||||
auth: {
|
||||
user: 'awesome_bell_ncc1hi',
|
||||
pass: '509f8938-db95-4b8d-83e7-9ea8eccfd28b'
|
||||
},
|
||||
tls: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
/// ///////////////////////////////////////////////////////////////// verify account functions
|
||||
function sendConfirmationEmail(userId) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
@@ -38,18 +49,7 @@ function sendConfirmationEmail(userId) {
|
||||
|
||||
/// //// email configs
|
||||
// const hostURL = 'www.asan-service.com'
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: 'smtp.c1.liara.email',
|
||||
port: 587,
|
||||
secure: false, // true for 465, false for other ports
|
||||
auth: {
|
||||
user: 'awesome_bell_ncc1hi',
|
||||
pass: '509f8938-db95-4b8d-83e7-9ea8eccfd28b'
|
||||
},
|
||||
tls: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const emailHTMLTemplate = `
|
||||
<div style="direction: rtl;background-color: #065495;overflow: hidden;">
|
||||
@@ -687,18 +687,7 @@ module.exports.generate_reset_user_password_link = [
|
||||
const hostURL = 'www.asan-service.com'
|
||||
|
||||
if (type === 'email') {
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: 'mail.asan-service.com',
|
||||
port: 587,
|
||||
secure: false, // true for 465, false for other ports
|
||||
auth: {
|
||||
user: 'resetpassword@asan-service.com',
|
||||
pass: '3e9atXQV+7a&'
|
||||
},
|
||||
tls: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const emailHTMLTemplate = `
|
||||
<div style="direction: rtl;background-color: #065495;overflow: hidden;">
|
||||
|
||||
Reference in New Issue
Block a user