example/ChatExample/app/controllers/users/users.password.server.controller.js
function(token, done) {
			if (req.body.username) {
				User.findOne({
					username: req.body.username
				}, '-salt -password', function(err, user) {
					if (!user) {
						return res.status(400).send({
							message: 'No account with that username has been found'
						});
					} else if (user.provider !== 'local') {
						return res.status(400).send({
							message: 'It seems like you signed up using your ' + user.provider + ' account'
						});
					} else {
						user.resetPasswordToken = token;
						user.resetPasswordExpires = Date.now() + 3600000; // 1 hour

						user.save(function(err) {
							done(err, token, user);
						});
					}
				});
			} else {
				return res.status(400).send({
					message: 'Username field must not be blank'
				});
			}
		}
function(token, done) {
			if (req.body.username) {
				User.findOne({
					username: req.body.username
				}, '-salt -password', function(err, user) {
					if (!user) {
						return res.status(400).send({
							message: 'No account with that username has been found'
						});
					} else if (user.provider !== 'local') {
						return res.status(400).send({
							message: 'It seems like you signed up using your ' + user.provider + ' account'
						});
					} else {
						user.resetPasswordToken = token;
						user.resetPasswordExpires = Date.now() + 3600000; // 1 hour

						user.save(function(err) {
							done(err, token, user);
						});
					}
				});
			} else {
				return res.status(400).send({
					message: 'Username field must not be blank'
				});
			}
		}
function ( token , done ) { if ( req . body . username ) { User . findOne ( { username : req . body . username } , '-salt -password' , function ( err , user ) { if ( ! user ) { return res . status ( 400 ) . send ( { message : 'No account with that username has been found' } ) ; } else if ( user . provider !== 'local' ) { return res . status ( 400 ) . send ( { message : 'It seems like you signed up using your ' + user . provider + ' account' } ) ; } else { user . resetPasswordToken = token ; user . resetPasswordExpires = Date . now ( ) + 3600000 ; // 1 hour user . save ( function ( err ) { done ( err , token , user ) ; } ) ; } } ) ; } else { return res . status ( 400 ) . send ( { message : 'Username field must not be blank' } ) ; } }
Lookup user by username
Lookup user by username