diff --git a/modules/articles/server/models/articles.server.model.js b/modules/articles/server/models/articles.server.model.js index e5200bc..1b9c450 100644 --- a/modules/articles/server/models/articles.server.model.js +++ b/modules/articles/server/models/articles.server.model.js @@ -20,4 +20,4 @@ module.exports = function(sequelize, DataTypes) { } }); return Article; -}; \ No newline at end of file +}; diff --git a/modules/articles/tests/server/article.server.model.tests.js b/modules/articles/tests/server/article.server.model.tests.js index 0f9dc5a..bf147bb 100644 --- a/modules/articles/tests/server/article.server.model.tests.js +++ b/modules/articles/tests/server/article.server.model.tests.js @@ -31,7 +31,6 @@ describe('Article Model Unit Tests:', function() { user.salt = user.makeSalt(); user.hashedPassword = user.encryptPassword('S3@n.jsI$Aw3$0m3', user.salt); - user.save().then(function(user) { article = Article.build({ title: 'Article Title', @@ -87,4 +86,4 @@ describe('Article Model Unit Tests:', function() { }).catch(function(err) {}); }); -}); \ No newline at end of file +}); diff --git a/modules/articles/tests/server/article.server.routes.tests.js b/modules/articles/tests/server/article.server.routes.tests.js index 64f0f72..75f348c 100644 --- a/modules/articles/tests/server/article.server.routes.tests.js +++ b/modules/articles/tests/server/article.server.routes.tests.js @@ -97,10 +97,6 @@ describe('Article CRUD tests', function() { // Get articles list var articles = articlesGetRes.body; - // Set assertions - console.log('articles[0]', articles[0]); - console.log('userId', userId); - //(articles[0].userId).should.equal(userId); (articles[0].title).should.match('Article Title'); @@ -350,4 +346,4 @@ describe('Article CRUD tests', function() { }).catch(function(err) {}); }); -}); \ No newline at end of file +}); diff --git a/modules/users/server/models/user.server.model.js b/modules/users/server/models/user.server.model.js index 39afc61..e68413d 100644 --- a/modules/users/server/models/user.server.model.js +++ b/modules/users/server/models/user.server.model.js @@ -125,20 +125,6 @@ module.exports = function(sequelize, DataTypes) { resetPasswordToken: DataTypes.STRING, resetPasswordExpires: DataTypes.BIGINT }, { - instanceMethods: { - makeSalt: function() { - return crypto.randomBytes(16).toString('base64'); - }, - authenticate: function(plainText) { - return this.encryptPassword(plainText, this.salt) === this.hashedPassword; - }, - encryptPassword: function(password, salt) { - if (!password || !salt) - return ''; - salt = new Buffer(salt, 'base64'); - return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64'); - } - }, classMethods: { findUniqueUsername: function(username, suffix, callback) { var _this = this; @@ -156,13 +142,29 @@ module.exports = function(sequelize, DataTypes) { } }); } - }, - associate: function(models) { - if (models.article) { - User.hasMany(models.article); - } } }); + User.prototype.makeSalt = function() { + return crypto.randomBytes(16).toString('base64'); + }; + + User.prototype.authenticate = function(plainText) { + return this.encryptPassword(plainText, this.salt) === this.hashedPassword; + }; + + User.prototype.encryptPassword = function(password, salt) { + if (!password || !salt) + return ''; + salt = new Buffer(salt, 'base64'); + return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64'); + }; + + User.associate = function(models) { + if (models.article) { + User.hasMany(models.article); + } + }; + return User; -}; \ No newline at end of file +}; diff --git a/modules/users/tests/server/user.server.model.tests.js b/modules/users/tests/server/user.server.model.tests.js index 7e503b0..1185643 100644 --- a/modules/users/tests/server/user.server.model.tests.js +++ b/modules/users/tests/server/user.server.model.tests.js @@ -129,7 +129,6 @@ describe('User Model Unit Tests:', function() { // should.not.exist((success) ? null : errorHandler.getErrorMessage(success)); // user1.roles = ['invalid-user-role-enum']; // user1.save().then(function(err) { - // console.log('err', err); // should.exist((err) ? err : null); // user1.destroy().then(function(err) { // should.not.exist((err) ? null : errorHandler.getErrorMessage(err)); @@ -584,4 +583,4 @@ describe('User Model Unit Tests:', function() { // done(); // }).catch(function(err) {}); }); -}); \ No newline at end of file +}); diff --git a/modules/users/tests/server/user.server.routes.tests.js b/modules/users/tests/server/user.server.routes.tests.js index 6f362b7..db606da 100644 --- a/modules/users/tests/server/user.server.routes.tests.js +++ b/modules/users/tests/server/user.server.routes.tests.js @@ -65,7 +65,6 @@ describe('User CRUD tests', function() { .end(function(signupErr, signupRes) { // Handle signpu error if (signupErr) { - console.log('signupErr', signupErr); return done(signupErr); } @@ -284,4 +283,4 @@ describe('User CRUD tests', function() { done(); }).catch(function(err) {}); }); -}); \ No newline at end of file +});