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,8 +71,8 @@ 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()
|
||||
|
||||
|
@ -80,6 +80,8 @@ AUTH.get('/captcha', async (req, res) => {
|
|||
res.contentType('image/png')
|
||||
.sendFile('captcha.png', { root: './' })
|
||||
})
|
||||
.catch(() => res.status(501).send("ERROR! Failed to generate captcha."))
|
||||
})
|
||||
|
||||
|
||||
export default AUTH
|
Loading…
Reference in New Issue
Block a user