examples/signup-login/app.js
function createUser(req, res, next){

        // the HTML form names are conveniently named the same as
        // the UserApp fields...
        var user = req.body;

        // Create the user in UserApp
        UserApp.User.save(user, function(err, user){

            // We can just pass through messages like "Password must be at least 5 characters." etc.
            if (err) return res.render('signup', {user: false, message: err.message});

            // UserApp passport needs a username parameter
            req.body.username = req.body.login;

            //on to authentication
            next();
        });

    // authenticate the user using passport
}
function createUser(req, res, next){

        // the HTML form names are conveniently named the same as
        // the UserApp fields...
        var user = req.body;

        // Create the user in UserApp
        UserApp.User.save(user, function(err, user){

            // We can just pass through messages like "Password must be at least 5 characters." etc.
            if (err) return res.render('signup', {user: false, message: err.message});

            // UserApp passport needs a username parameter
            req.body.username = req.body.login;

            //on to authentication
            next();
        });

    // authenticate the user using passport
}
function createUser ( req , res , next ) { // the HTML form names are conveniently named the same as // the UserApp fields... var user = req . body ; // Create the user in UserApp UserApp . User . save ( user , function ( err , user ) { // We can just pass through messages like "Password must be at least 5 characters." etc. if ( err ) return res . render ( 'signup' , { user : false , message : err . message } ) ; // UserApp passport needs a username parameter req . body . username = req . body . login ; //on to authentication next ( ) ; } ) ; // authenticate the user using passport }
first we need to create the user in UserApp
first we need to create the user in UserApp