lib/controllers/actions/reset.js
function sendEmail(req, res, sails, params){
  sails.models.auth.findOne({email: params.email}).populate('user').exec(function(err, a){
    if(a){
      sails.models.resettoken.create({owner: a.id}).exec(function(err, t){
        if(err){
          return res.serverError(err);
        }
        sails.models.auth.update({id: a.id}, {resetToken: t.id}).exec(function(err){
          if(err){
            return res.serverError(err);
          }
          res.json(200);
        });
      });
    } else {
      return res.forbidden('Email not found');
    }
  });
}
function sendEmail(req, res, sails, params){
  sails.models.auth.findOne({email: params.email}).populate('user').exec(function(err, a){
    if(a){
      sails.models.resettoken.create({owner: a.id}).exec(function(err, t){
        if(err){
          return res.serverError(err);
        }
        sails.models.auth.update({id: a.id}, {resetToken: t.id}).exec(function(err){
          if(err){
            return res.serverError(err);
          }
          res.json(200);
        });
      });
    } else {
      return res.forbidden('Email not found');
    }
  });
}
function sendEmail ( req , res , sails , params ) { sails . models . auth . findOne ( { email : params . email } ) . populate ( 'user' ) . exec ( function ( err , a ) { if ( a ) { sails . models . resettoken . create ( { owner : a . id } ) . exec ( function ( err , t ) { if ( err ) { return res . serverError ( err ) ; } sails . models . auth . update ( { id : a . id } , { resetToken : t . id } ) . exec ( function ( err ) { if ( err ) { return res . serverError ( err ) ; } res . json ( 200 ) ; } ) ; } ) ; } else { return res . forbidden ( 'Email not found' ) ; } } ) ; }
Begins the reset process by creating a new reset token
and sending an email to the user
@param  object req the express request object
@param  object res the express response object
@param  waterlineDAO User  the waterline User dao
@param  waterlineDAO ResetToken the waterline ResetToken dao
@param  object params all params for this request
Begins the reset process by creating a new reset token and sending an email to the user