diff --git a/app/initialData.js b/app/initialData.js index 2adf344..08a58dd 100644 --- a/app/initialData.js +++ b/app/initialData.js @@ -8,7 +8,7 @@ module.exports = function(sequelize) { if(count == 0) { var basicJarIds = []; - models.User.create({login: 'wcrisman', password: models.User.generateHash('landFJ40'), admin: true}); + models.User.create({login: 'wcrisman', password: 'landFJ40', admin: true}); models.Venue.create({name: 'Boonville'}); models.Venue.create({name: 'Clement St Farmers Market in SF'}); diff --git a/app/passport.js b/app/passport.js index 04b65c8..fa945c5 100644 --- a/app/passport.js +++ b/app/passport.js @@ -76,7 +76,7 @@ module.exports = function(passport, User) { if(!user) { return done(null, false, req.flash('loginMessage', 'User not found.')); } - else if(!user.validPassword(password)) { + else if(!user.isPasswordValid(password)) { return done(null, false, req.flash('loginMessage', 'Invalid password.')); } else { diff --git a/migrations/20160602030150-Sale.js b/migrations/20160602030150-Sale.js index 227c0ef..bedf924 100644 --- a/migrations/20160602030150-Sale.js +++ b/migrations/20160602030150-Sale.js @@ -23,7 +23,7 @@ module.exports = { type: DataTypes.DECIMAL(13,4), allowNull: false }, - measure: { + measureId: { type: Sequelize.INTEGER, references: { model: 'Measure', diff --git a/models/sale.js b/models/sale.js index 8dff827..d5b64b0 100644 --- a/models/sale.js +++ b/models/sale.js @@ -29,14 +29,10 @@ module.exports = function(sequelize, DataTypes) { updatedAt: { type: DataTypes.DATE, allowNull: false - }, - deletedAt: { - type: DataTypes.DATE, - allowNull: true } }, { freezeTableName: true, // Model tableName will be the same as the model name - paranoid: true, + paranoid: false, classMethods: { associate: function(models) { Sale.belongsTo(models.Item, {as: 'item', foreignKey: {name: 'itemId', field: 'itemId'}}); diff --git a/models/user.js b/models/user.js index dfd67d9..906f592 100644 --- a/models/user.js +++ b/models/user.js @@ -14,10 +14,10 @@ module.exports = function(sequelize, DataTypes) { login: { type: DataTypes.STRING }, - password: { + password: { //Note: The salt should be stored as part of the hash. type: DataTypes.STRING, set: function(val) { - this.setDataValue('password', sequelize.models.User.generateHash(val)); + this.setDataValue('password', bcrypt.hashSync(val, bcrypt.genSaltSync(8), null)); } }, admin: { @@ -35,16 +35,8 @@ module.exports = function(sequelize, DataTypes) { freezeTableName: true, // Model tableName will be the same as the model name //paranoid: true, //Keep deleted data but flag it as deleted comment: "A system user authorized to access and manipulate the application data.", - classMethods: { - generateHash: function(password) { - return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); - } - }, instanceMethods: { - generateHash: function(password) { - return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); - }, - validPassword: function(password) { + isPasswordValid: function(password) { return bcrypt.compareSync(password, this.password); } } diff --git a/public/admin/Venues.html b/public/admin/Venues.html index 51cf856..e673010 100644 --- a/public/admin/Venues.html +++ b/public/admin/Venues.html @@ -1,13 +1,11 @@
-
+
+
+

Manage Venues

- -

Manage Venues

- -
@@ -25,238 +23,258 @@ +
- -