Commit project

This commit is contained in:
Rodrigo Pedroso 2019-06-19 10:46:14 -04:00
commit 3ac017a5ad
1030 changed files with 94062 additions and 0 deletions

26
passport/local-signup.js Normal file
View file

@ -0,0 +1,26 @@
const Merchant = require('mongoose').model('Merchant');
const localStrategy = require('passport-local').Strategy;
module.exports = new localStrategy({
usernameField: 'merchant_email',
passwordField: 'password',
session: false,
passReqToCallback: true
}, (req, email, password, done) => {
const userData = {
merchant_email: email.trim(),
password: password.trim(),
merchant_name: req.body.merchant_name.trim(),
number: req.body.number
};
const newMerchant = new Merchant(userData);
newMerchant.save((err, doc) => {
if (err) {
console.log('Err: ' + err);
return done(err);
}
return done(null, doc);
});
});