Working on password recovery

This commit is contained in:
2021-07-28 23:02:04 +10:00
parent 72b3babfd8
commit 81da8ca422
9 changed files with 224 additions and 1 deletions
+19
View File
@@ -0,0 +1,19 @@
const { accounts, recovery } = require('../database/models');
//auth/reset
const route = async (req, res) => {
//verify the recovery record exists
const record = recovery.findOne({
token: req.query.token
});
if (!record) {
return res.status(401).end('Failed to recover a password');
}
//redirect to the front-end
res.redirect(`${process.env.WEB_PROTOCOL}${process.env.WEB_RESET_ADDRESS}?email=${record.email}&token=${record.token}`);
return null;
};
module.exports = route;