diff --git a/app.js b/app.js index 0ca530eb..b8ec4437 100644 --- a/app.js +++ b/app.js @@ -24,6 +24,7 @@ app.use(session({ })); //for static files app.use(express.static(path.join(__dirname, 'public'))); +app.use('/icoDashboardSetup/project', express.static(__dirname + '/icoDashboardCreator/dist')); app.use(cookieParser()); app.use(passport.initialize()); app.use(passport.session()); // persistent login sessions diff --git a/coinPayments/impl.js b/coinPayments/impl.js index 381f0e55..fd7a9cf0 100644 --- a/coinPayments/impl.js +++ b/coinPayments/impl.js @@ -5,9 +5,9 @@ let Promise = require('bluebird'); module.exports = { - buyToken: (currency1, currency2, amount, buyer_email) => { + buyToken: (currency1, currency2, amount, buyer_email, address) => { return new Promise((resolve, reject) => { - client.createTransaction({'currency1' : currency1, 'currency2' : currency2, 'amount' : amount, 'buyer_email':buyer_email}).then(txInfo => { + client.createTransaction({'currency1' : currency1, 'currency2' : currency2, 'amount' : amount, 'buyer_email':buyer_email, 'address': address}).then(txInfo => { resolve(txInfo); }); }) diff --git a/config/passport.js b/config/passport.js index bb8f2446..9657568a 100644 --- a/config/passport.js +++ b/config/passport.js @@ -11,6 +11,7 @@ var Currency = db.currency; var Address = db.userCurrencyAddress; var Transactions = db.icotransactions; var Project = db.projectConfiguration; +var bitcoin = require("bitcoinjs-lib"); let Promise = require('bluebird'); var bcrypt = require('bcrypt-nodejs'); const Web3 = require('web3'); @@ -78,12 +79,18 @@ module.exports = function (passport) { } }); - var projectCurrency = await db.currency.findOrCreate({ + var btcCurrency = await db.currency.findOrCreate({ where: { - 'name': req.body.projectName + 'name': "Bitcoin" } }); + // var projectCurrency = await db.currency.findOrCreate({ + // where: { + // 'name': req.body.projectName + // } + // }); + console.log(req.body.projectName); //Find project details and map user var project = await Project.findOrCreate({ @@ -92,11 +99,11 @@ module.exports = function (passport) { } }); - Promise.all([generateEthAddress(), generateEthAddress(), createNewUser(req)]).then(([createdEthAddress, createdCoinAddress, createdUser]) => { + Promise.all([generateEthAddress(), generateBTCAddress(), createNewUser(req)]).then(([createdEthAddress, createdBTCAddress, createdUser]) => { ethCurrency[0].addUserCurrencyAddress(createdEthAddress); - projectCurrency[0].addUserCurrencyAddress(createdCoinAddress); - createdUser.addUserCurrencyAddresses([createdEthAddress, createdCoinAddress]); - project[0].addUserCurrencyAddress([createdEthAddress, createdCoinAddress]); + btcCurrency[0].addUserCurrencyAddress(createdBTCAddress); + createdUser.addUserCurrencyAddresses([createdEthAddress, createdBTCAddress]); + project[0].addUserCurrencyAddresses([createdEthAddress, createdBTCAddress]); project[0].addUser(createdUser); return done(null, createdUser.dataValues); }); @@ -317,7 +324,6 @@ function generateEthAddress() { return new Promise(async function (resolve, reject) { var newEthAddress = new Object(); var keyStore = generateNewAccount(); - console.log(keyStore); newEthAddress.privateKey = keyStore.privateKey; newEthAddress.address = keyStore.address; var createdEthAddress = await Address.create(newEthAddress); @@ -325,6 +331,20 @@ function generateEthAddress() { }); } +function generateBTCAddress() { + return new Promise(async function (resolve, reject) { + var newBTCAddress = new Object(); + const TestNet = bitcoin.networks.testnet; + var keyPair = bitcoin.ECPair.makeRandom(); + let { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey }); + console.log(address); + newBTCAddress.address = address; + newBTCAddress.privateKey = keyPair.toWIF(); + var createdBTCAddress = await Address.create(newBTCAddress); + resolve(createdBTCAddress); + }); +} + function createNewUser(req) { return new Promise(async function (resolve, reject) { var newUser = new Object(); @@ -335,7 +355,7 @@ function createNewUser(req) { newUser.lastName = req.body.last_name; newUser.country = req.body.country_id; var createdUser = await User.create(newUser); - sendVerificationMail(req, createdUser.email, createdUser.firstName, createdUser.uniqueId); + sendUserVerificationMail(req, createdUser.email, createdUser.firstName, createdUser.uniqueId); resolve(createdUser); }); } @@ -356,3 +376,8 @@ function sendVerificationMail(req, userEmail, userName, userHash) { var nodemailerservice = require('../emailer/impl'); nodemailerservice.sendVerificationMail(req, userEmail, userName, userHash); } + +function sendUserVerificationMail(req, userEmail, userName, userHash) { + var nodemailerservice = require('../emailer/impl'); + nodemailerservice.sendUserVerificationMail(req, userEmail, userName, userHash); +} diff --git a/database/config/config.json b/database/config/config.json index f87a92a9..64ae6a1c 100644 --- a/database/config/config.json +++ b/database/config/config.json @@ -3,7 +3,7 @@ "username": "postgres", "password": "123", "database": "autoCoin", - "host": "localhost", + "host": "78.129.212.204", "logging": false, "freezeTableName": true, "operatorsAliases": false, diff --git a/emailer/impl.js b/emailer/impl.js index 8a691e4b..f433877e 100644 --- a/emailer/impl.js +++ b/emailer/impl.js @@ -54,6 +54,23 @@ module.exports = { triggerEmail(mailOptions); }); }, + + sendUserVerificationMail: function (req, recipientmail, name, userhash) { + var link = "http://" + req.get('host') + "/verifyMail?verificationId=" + userhash; + ejs.renderFile(__dirname + '/emailerTemplates/emailVerification.ejs', { + name: name, + link: link + }, (err, data) => { + console.log(err); + var mailOptions = { + from: "emailverification@autocoin.com", + to: recipientmail, + subject: "Email Verification", + html: data + }; + triggerEmail(mailOptions); + }); + }, //OTP sendConfirmationOTP: function (recipientmail, otp) { ejs.renderFile(__dirname + '/emailerTemplates/packageOTPMailer.ejs', { diff --git a/icoDashboardCreator/dist/index.ejs b/icoDashboardCreator/dist/index.ejs index 866f6c36..431bb59a 100644 --- a/icoDashboardCreator/dist/index.ejs +++ b/icoDashboardCreator/dist/index.ejs @@ -3,12 +3,12 @@
-3.21.07
- - + +