Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
chi_Script committed Jul 10, 2018
1 parent 40a47eb commit 7dcc34a
Show file tree
Hide file tree
Showing 8 changed files with 269 additions and 162 deletions.
5 changes: 5 additions & 0 deletions .env.process
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_USERNAME=palandas
DB_PASSWORD=''
DB_NAME=postgres
DB_HOST=localhost
SECRET_KEY=newpassword
18 changes: 1 addition & 17 deletions config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,5 @@ passport.deserializeUser((id, done) =>{
done(err, user);
})
})
// let opts = {};
// opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('jwt');
// opts.secretOrKey = 'newpassword';
// passport.use(
// new LocalStrategy(opts, (jwt_payload, done) => {
// User.getUserById( jwt_payload._doc._id, (err, user) => {
// if (err) {
// return done(err, false);
// }
// if (user) {
// done(null, user);
// } else {
// done(null, false);
// }
// });
// })
// );

}
24 changes: 20 additions & 4 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ const Strategy = require('passport-local')
const sequelize = new Sequelize("palandas", "postgres", "newpassword", {
host: "localhost",
dialect: "postgres",
operatorsAliases: false
})
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}

})
sequelize.sync({force: false});
const User = sequelize.define(
'User',
{
Expand All @@ -31,7 +39,15 @@ const User = sequelize.define(
User.password = bcrypt.hashSync(User.password, 10);
}
}
}
},
// user.sync({force: true}).then(() => {
// // Table created
// return User.create({
// email: 'John',
// password: 'Hancock'
// });
// })

);


Expand All @@ -54,7 +70,7 @@ module.exports.getUserById = (id, cb) => {
User.findById(id, cb);
}
module.exports.getUserByEmail = (email, cb) => {
User.findOne({email:email}, cb);
User.findAndCreate({email:email}, cb);
}
module.exports.createUser = (newUser, cb) => {
bcrypt.genSalt(10, (err, salt)=>{
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "server.js",
"scripts": {
"test": "mocha test/**/*.js",
"test": "mocha test/**/*.js --timeout 10,000",
"start": "node server.js"
},
"keywords": [],
Expand Down
Loading

0 comments on commit 7dcc34a

Please sign in to comment.