Advertisement
Guest User

Untitled

a guest
Jun 20th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. const randomstring = require("randomstring")
  2. exports.forgotPassword = function (req, res){
  3. var random = Common.encrypt(randomstring.generate({length: 5, charset: 'alphabetic'}));
  4. User.findUserUpdate({username: req.body.username}, {password: random}, function(err, user) {
  5. if (!err) {
  6. if (user === null){
  7. return res.send(Boom.forbidden("invalid username"));
  8. }
  9. else{
  10. Common.sentMailForgotPassword(user);
  11. return res.send("password is send to registered email id");
  12. }
  13. } else {
  14. return res.send(Boom.badImplementation(err));
  15. }
  16. })
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement