Smol refactor.
This commit is contained in:
parent
2af34eb35f
commit
90c099f497
|
@ -4,9 +4,9 @@ export default function execawait(cmd) {
|
|||
return new Promise((resolve, reject) => {
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.warn(error);
|
||||
console.warn(error)
|
||||
}
|
||||
resolve(stdout ? stdout : stderr);
|
||||
});
|
||||
});
|
||||
stdout ? resolve(stdout) : reject(stderr)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -71,14 +71,16 @@ AUTH.post('/login', (req, res) => {
|
|||
|
||||
AUTH.get('/captcha', async (req, res) => {
|
||||
const captcha = crypto.randomBytes(3).toString('hex')
|
||||
await execawait(`./captcha.sh ${captcha} > captcha.png`)
|
||||
|
||||
execawait(`./captcha.sh ${captcha} > captcha.png`)
|
||||
.then(() => {
|
||||
// Make it valid for 10 minutes
|
||||
valid[captcha] = new Date()
|
||||
|
||||
// Send the captcha image
|
||||
res.contentType('image/png')
|
||||
.sendFile('captcha.png', { root: './' })
|
||||
})
|
||||
.catch(() => res.status(501).send("ERROR! Failed to generate captcha."))
|
||||
})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user