controller/token_controller.js
function (req, res, next) {
	// console.log('req.body', req.body);
	// console.log('req.params', req.params);
  var user_token = req.params.token || req.body.token; //req.controllerData.token;
  waterfall([
    function (cb) {
      cb(null, req, res, next);
    },
    invalidateUserToken,
    resetPassword,
    saveUser,
    emailResetPasswordNotification,
  ],
		function (err, results) {
  if (periodic.app.controller.extension.reactadmin) {
    let reactadmin = periodic.app.controller.extension.reactadmin;
    if (err) {
      res.status(400).send({
        result: 'error',
        data: {
          error:err.toString(),
        },
      });
    } else {
      res.status(200).send({
        result: 'success',
        data:'Password successfully changed',
      });
    }
  } else { 
				// console.log('These are the err', err);
				// console.log('These are the results', results);
    CoreController.respondInKind({
      req: req,
      res: res,
      err: err,
      responseData: results || {},
      callback: function (req, res /*,responseData*/ ) {
						// console.log('err',err,'/auth/reset/' + user_token);
        if (err) {
							// console.log('return to reset');
          req.flash('error', err.message);
          res.redirect('/auth/reset/' + user_token);
        }						else {
							// console.log('no return to x');
          req.flash('success', 'Password Sucessfully Changed!');
          res.redirect(loginExtSettings.settings.authLoginPath);
        }
      },
    });
  }
});
}
function (req, res, next) {
	// console.log('req.body', req.body);
	// console.log('req.params', req.params);
  var user_token = req.params.token || req.body.token; //req.controllerData.token;
  waterfall([
    function (cb) {
      cb(null, req, res, next);
    },
    invalidateUserToken,
    resetPassword,
    saveUser,
    emailResetPasswordNotification,
  ],
		function (err, results) {
  if (periodic.app.controller.extension.reactadmin) {
    let reactadmin = periodic.app.controller.extension.reactadmin;
    if (err) {
      res.status(400).send({
        result: 'error',
        data: {
          error:err.toString(),
        },
      });
    } else {
      res.status(200).send({
        result: 'success',
        data:'Password successfully changed',
      });
    }
  } else { 
				// console.log('These are the err', err);
				// console.log('These are the results', results);
    CoreController.respondInKind({
      req: req,
      res: res,
      err: err,
      responseData: results || {},
      callback: function (req, res /*,responseData*/ ) {
						// console.log('err',err,'/auth/reset/' + user_token);
        if (err) {
							// console.log('return to reset');
          req.flash('error', err.message);
          res.redirect('/auth/reset/' + user_token);
        }						else {
							// console.log('no return to x');
          req.flash('success', 'Password Sucessfully Changed!');
          res.redirect(loginExtSettings.settings.authLoginPath);
        }
      },
    });
  }
});
}
function ( req , res , next ) { // console.log('req.body', req.body); // console.log('req.params', req.params); var user_token = req . params . token || req . body . token ; //req.controllerData.token; waterfall ( [ function ( cb ) { cb ( null , req , res , next ) ; } , invalidateUserToken , resetPassword , saveUser , emailResetPasswordNotification , ] , function ( err , results ) { if ( periodic . app . controller . extension . reactadmin ) { let reactadmin = periodic . app . controller . extension . reactadmin ; if ( err ) { res . status ( 400 ) . send ( { result : 'error' , data : { error : err . toString ( ) , } , } ) ; } else { res . status ( 200 ) . send ( { result : 'success' , data : 'Password successfully changed' , } ) ; } } else { // console.log('These are the err', err); // console.log('These are the results', results); CoreController . respondInKind ( { req : req , res : res , err : err , responseData : results || { } , callback : function ( req , res /*,responseData*/ ) { // console.log('err',err,'/auth/reset/' + user_token); if ( err ) { // console.log('return to reset'); req . flash ( 'error' , err . message ) ; res . redirect ( '/auth/reset/' + user_token ) ; } else { // console.log('no return to x'); req . flash ( 'success' , 'Password Sucessfully Changed!' ) ; res . redirect ( loginExtSettings . settings . authLoginPath ) ; } } , } ) ; } } ) ; }
POST change the users old password to the new password in the form
POST change the users old password to the new password in the form