|
@ -71,7 +71,7 @@ const User = sequelize.define('User', { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
User.sync().then(() => { |
|
|
User.sync().then(() => { |
|
|
if(process.env.ADMIN_USERNAME && process.env.ADMIN_PASSWORD){ |
|
|
|
|
|
|
|
|
if (process.env.ADMIN_USERNAME && process.env.ADMIN_PASSWORD) { |
|
|
User.create({ |
|
|
User.create({ |
|
|
telegram: process.env.ADMIN_USERNAME, |
|
|
telegram: process.env.ADMIN_USERNAME, |
|
|
hash: bcrypt.hashSync(process.env.ADMIN_PASSWORD, 10), |
|
|
hash: bcrypt.hashSync(process.env.ADMIN_PASSWORD, 10), |
|
@ -112,13 +112,17 @@ function createQRCode(telegram, done) { |
|
|
where: { |
|
|
where: { |
|
|
telegram: telegram |
|
|
telegram: telegram |
|
|
} |
|
|
} |
|
|
}).then(user => { |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
.then(user => { |
|
|
refreshVerification(user, result => { |
|
|
refreshVerification(user, result => { |
|
|
const verifyURL = `${process.env.WEBSITE_URL}/#/verify/${encodeURIComponent(result.verification)}`; |
|
|
const verifyURL = `${process.env.WEBSITE_URL}/#/verify/${encodeURIComponent(result.verification)}`; |
|
|
QRCode.toDataURL(verifyURL, { width: 300, height: 300 }, (err, url) => { |
|
|
QRCode.toDataURL(verifyURL, { width: 300, height: 300 }, (err, url) => { |
|
|
done(err, url); |
|
|
done(err, url); |
|
|
}) |
|
|
}) |
|
|
}); |
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
done(err); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -227,7 +231,7 @@ app.get('/code', (req, res) => { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
createQRCode(req.session.user, (err, url) => { |
|
|
createQRCode(req.session.user, (err, url) => { |
|
|
res.send({ error: err, data: url }); |
|
|
|
|
|
|
|
|
res.status(url ? 200 : 401).send({ error: err, data: url }); |
|
|
}); |
|
|
}); |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|