const user_reset = (request, response) => {
const { token } = request.params;
const pw = Math.random().toString(36).slice(2, 10);
jwt.verify(token, secret, (err, t) => {
if (err) return response.status(404).send({ error: 'invalid request' });
User.findByIdAndUpdate(t._id, { $set: { password: pw } })
.then((u) => {
const mailOptions = {
from: username,
to: u.email,
subject: 'Password Reset',
text: `Your password has been reset as requested. You should now use the password ${pw} to login.`,