fix some minor eslint errors

This commit is contained in:
catarak 2016-06-27 13:09:18 -04:00
parent e18a5e0941
commit 2bdd682771
3 changed files with 15 additions and 14 deletions

View file

@ -1,8 +1,8 @@
const passport = require('passport');
const GitHubStrategy = require('passport-github').Strategy;
// const GitHubStrategy = require('passport-github').Strategy;
const LocalStrategy = require('passport-local').Strategy;
import User from '../models/user'
import User from '../models/user';
passport.serializeUser((user, done) => {
done(null, user.id);
@ -18,11 +18,11 @@ passport.deserializeUser((id, done) => {
* Sign in using Email and Password.
*/
passport.use(new LocalStrategy({ usernameField: 'email' }, (email, password, done) => {
User.findOne({ email: email.toLowerCase() }, (err, user) => {
User.findOne({ email: email.toLowerCase() }, (err, user) => { // eslint-disable-line consistent-return
if (!user) {
return done(null, false, { msg: `Email ${email} not found.` });
}
user.comparePassword(password, (err, isMatch) => {
user.comparePassword(password, (innerErr, isMatch) => {
if (isMatch) {
return done(null, user);
}
@ -34,7 +34,7 @@ passport.use(new LocalStrategy({ usernameField: 'email' }, (email, password, don
/**
* Sign in with GitHub.
*/
//TODO add dotenv so I can add github login
// TODO add github login
// passport.use(new GitHubStrategy({
// clientID: process.env.GITHUB_ID,
// clientSecret: process.env.GITHUB_SECRET,

View file

@ -15,15 +15,15 @@ const userSchema = new Schema({
/**
* Password hash middleware.
*/
userSchema.pre('save', function (next) {
userSchema.pre('save', function checkPassword(next) { // eslint-disable-line consistent-return
const user = this;
if (!user.isModified('password')) { return next(); }
bcrypt.genSalt(10, (err, salt) => {
if (err) { return next(err); }
bcrypt.hash(user.password, salt, null, (err, hash) => {
bcrypt.genSalt(10, (err, salt) => { // eslint-disable-line consistent-return
if (err) { return next(err); }
bcrypt.hash(user.password, salt, null, (innerErr, hash) => {
if (innerErr) { return next(innerErr); }
user.password = hash;
next();
return next();
});
});
});
@ -31,7 +31,7 @@ userSchema.pre('save', function (next) {
/**
* Helper method for validating user's password.
*/
userSchema.methods.comparePassword = function (candidatePassword, cb) {
userSchema.methods.comparePassword = function comparePassword(candidatePassword, cb) {
// userSchema.methods.comparePassword = (candidatePassword, cb) => {
bcrypt.compare(candidatePassword, this.password, (err, isMatch) => {
cb(err, isMatch);

View file

@ -58,7 +58,8 @@ app.use('/api', projects);
app.use('/', serverRoutes);
// configure passport
const passportConfig = require('./config/passport');
require('./config/passport');
// const passportConfig = require('./config/passport');
// Connect to MongoDB
// mongoose.connect(process.env.MONGODB_URI || process.env.MONGOLAB_URI);