Commit project
This commit is contained in:
parent
28471965a0
commit
3ac017a5ad
1030 changed files with 94062 additions and 0 deletions
26
passport/local-signup.js
Normal file
26
passport/local-signup.js
Normal 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);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue