From a1e157cb631092ef72f529e5a3886e1f175e8357 Mon Sep 17 00:00:00 2001 From: git-admin Date: Tue, 17 Feb 2015 13:27:12 +0100 Subject: [PATCH 1/4] Use validator.js instead of regexp for validations in User Schema. --- app/models/user.server.model.js | 15 +++- package.json | 143 ++++++++++++++++---------------- 2 files changed, 83 insertions(+), 75 deletions(-) mode change 100755 => 100644 package.json diff --git a/app/models/user.server.model.js b/app/models/user.server.model.js index 840464af0a..70c6eeb25f 100755 --- a/app/models/user.server.model.js +++ b/app/models/user.server.model.js @@ -5,7 +5,8 @@ */ var mongoose = require('mongoose'), Schema = mongoose.Schema, - crypto = require('crypto'); + crypto = require('crypto'), + validator = require('validator'); /** * A Validation function for local strategy properties @@ -18,7 +19,14 @@ var validateLocalStrategyProperty = function(property) { * A Validation function for local strategy password */ var validateLocalStrategyPassword = function(password) { - return (this.provider !== 'local' || (password && password.length > 6)); + return (this.provider !== 'local' || validator.isLength(password, 6)); +}; + +/** + * A Validation function for local strategy email + */ +var validateLocalStrategyEmail = function(email) { + return ((this.provider !== 'local' && !this.updated) || validator.isEmail(email)); }; /** @@ -45,8 +53,7 @@ var UserSchema = new Schema({ type: String, trim: true, default: '', - validate: [validateLocalStrategyProperty, 'Please fill in your email'], - match: [/.+\@.+\..+/, 'Please fill a valid email address'] + validate: [validateLocalStrategyEmail, 'Please fill a valid email address'] }, username: { type: String, diff --git a/package.json b/package.json old mode 100755 new mode 100644 index 7807d2716c..f8e219562b --- a/package.json +++ b/package.json @@ -1,73 +1,74 @@ { - "name": "meanjs", - "description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.", - "version": "0.3.3", - "private": false, - "author": "https://github.com/meanjs/mean/graphs/contributors", - "repository": { - "type": "git", - "url": "https://github.com/meanjs/mean.git" - }, - "engines": { - "node": ">=0.10.28", - "npm": ">=1.4.28" - }, - "scripts": { - "start": "grunt", - "test": "grunt test", - "postinstall": "bower install --config.interactive=false" - }, - "dependencies": { - "express": "~4.10.1", - "express-session": "~1.9.1", - "body-parser": "~1.9.0", - "cookie-parser": "~1.3.2", - "compression": "~1.2.0", - "method-override": "~2.3.0", - "morgan": "~1.4.1", - "connect-mongo": "~0.4.1", - "connect-flash": "~0.1.1", - "helmet": "~0.5.0", - "consolidate": "~0.10.0", - "swig": "~1.4.1", - "mongoose": "~3.8.8", - "passport": "~0.2.0", - "passport-local": "~1.0.0", - "passport-facebook": "~1.0.2", - "passport-twitter": "~1.0.2", - "passport-linkedin": "~0.1.3", - "passport-google-oauth": "~0.1.5", - "passport-github": "~0.1.5", - "lodash": "~2.4.1", - "forever": "~0.11.0", - "bower": "~1.3.8", - "grunt-cli": "~0.1.13", - "glob": "~4.0.5", - "async": "~0.9.0", - "nodemailer": "~1.3.0", - "chalk": "~0.5" - }, - "devDependencies": { - "supertest": "~0.14.0", - "should": "~4.1.0", - "grunt-env": "~0.4.1", - "grunt-node-inspector": "~0.1.3", - "grunt-contrib-watch": "~0.6.1", - "grunt-contrib-jshint": "~0.10.0", - "grunt-contrib-csslint": "^0.3.1", - "grunt-ng-annotate": "~0.4.0", - "grunt-contrib-uglify": "~0.6.0", - "grunt-contrib-cssmin": "~0.10.0", - "grunt-nodemon": "~0.3.0", - "grunt-concurrent": "~1.0.0", - "grunt-mocha-test": "~0.12.1", - "grunt-karma": "~0.9.0", - "load-grunt-tasks": "~1.0.0", - "karma": "~0.12.0", - "karma-jasmine": "~0.2.1", - "karma-coverage": "~0.2.0", - "karma-chrome-launcher": "~0.1.2", - "karma-firefox-launcher": "~0.1.3", - "karma-phantomjs-launcher": "~0.1.2" - } + "name": "meanjs", + "description": "Full-Stack JavaScript with MongoDB, Express, AngularJS, and Node.js.", + "version": "0.3.3", + "private": false, + "author": "https://github.com/meanjs/mean/graphs/contributors", + "repository": { + "type": "git", + "url": "https://github.com/meanjs/mean.git" + }, + "engines": { + "node": ">=0.10.28", + "npm": ">=1.4.28" + }, + "scripts": { + "start": "grunt", + "test": "grunt test", + "postinstall": "bower install --config.interactive=false" + }, + "dependencies": { + "async": "~0.9.0", + "body-parser": "~1.9.0", + "bower": "~1.3.8", + "chalk": "~0.5", + "compression": "~1.2.0", + "connect-flash": "~0.1.1", + "connect-mongo": "~0.4.1", + "consolidate": "~0.10.0", + "cookie-parser": "~1.3.2", + "express": "~4.10.1", + "express-session": "~1.9.1", + "forever": "~0.11.0", + "glob": "~4.0.5", + "grunt-cli": "~0.1.13", + "helmet": "~0.5.0", + "lodash": "~2.4.1", + "method-override": "~2.3.0", + "mongoose": "~3.8.8", + "morgan": "~1.4.1", + "nodemailer": "~1.3.0", + "passport": "~0.2.0", + "passport-facebook": "~1.0.2", + "passport-github": "~0.1.5", + "passport-google-oauth": "~0.1.5", + "passport-linkedin": "~0.1.3", + "passport-local": "~1.0.0", + "passport-twitter": "~1.0.2", + "swig": "~1.4.1", + "validator": "^3.30.0" + }, + "devDependencies": { + "supertest": "~0.14.0", + "should": "~4.1.0", + "grunt-env": "~0.4.1", + "grunt-node-inspector": "~0.1.3", + "grunt-contrib-watch": "~0.6.1", + "grunt-contrib-jshint": "~0.10.0", + "grunt-contrib-csslint": "^0.3.1", + "grunt-ng-annotate": "~0.4.0", + "grunt-contrib-uglify": "~0.6.0", + "grunt-contrib-cssmin": "~0.10.0", + "grunt-nodemon": "~0.3.0", + "grunt-concurrent": "~1.0.0", + "grunt-mocha-test": "~0.12.1", + "grunt-karma": "~0.9.0", + "load-grunt-tasks": "~1.0.0", + "karma": "~0.12.0", + "karma-jasmine": "~0.2.1", + "karma-coverage": "~0.2.0", + "karma-chrome-launcher": "~0.1.2", + "karma-firefox-launcher": "~0.1.3", + "karma-phantomjs-launcher": "~0.1.2" + } } From 9a1dd22506103975550c79a34ac64308d9c13b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fer=20Uri=CC=81a?= Date: Wed, 18 May 2016 11:17:51 +0200 Subject: [PATCH 2/4] Disables "Unexpected console statement no-console" warnings --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index f03e9c512d..e61935fb47 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,7 @@ module.exports = { 'new-cap': [2, { newIsCapExceptions: ['acl.memoryBackend', 'acl'] }], 'no-bitwise': 0, 'no-caller': 2, + 'no-console': 0, 'no-else-return': 0, 'no-empty-class': 0, 'no-multi-spaces': 2, From edc663fd960d3a38340d21d3f369c5003e699ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fer=20Uri=CC=81a?= Date: Mon, 30 May 2016 13:49:36 +0200 Subject: [PATCH 3/4] Fixes redirection to wrong URL after login with social networks. --- .../users/users.authentication.server.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/users/server/controllers/users/users.authentication.server.controller.js b/modules/users/server/controllers/users/users.authentication.server.controller.js index c88497f0b8..f742ffa2ff 100644 --- a/modules/users/server/controllers/users/users.authentication.server.controller.js +++ b/modules/users/server/controllers/users/users.authentication.server.controller.js @@ -104,7 +104,7 @@ exports.oauthCallback = function (strategy) { var sessionRedirectURL = req.session.redirect_to; delete req.session.redirect_to; - passport.authenticate(strategy, function (err, user, redirectURL) { + passport.authenticate(strategy, function (err, user, info) { if (err) { return res.redirect('/authentication/signin?err=' + encodeURIComponent(errorHandler.getErrorMessage(err))); } @@ -116,7 +116,7 @@ exports.oauthCallback = function (strategy) { return res.redirect('/authentication/signin'); } - return res.redirect(redirectURL || sessionRedirectURL || '/'); + return res.redirect(sessionRedirectURL || '/'); }); })(req, res, next); }; From 66c6dc570ffb47853ba54d4417a4be108130ac74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fer=20Uri=CC=81a?= Date: Fri, 3 Jun 2016 13:36:23 +0200 Subject: [PATCH 4/4] Use ViewModel vm instead of $scope in manage social accounts controller. --- .../settings/manage-social-accounts.client.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js index f6411a43af..03f6548e96 100644 --- a/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js +++ b/modules/users/client/controllers/settings/manage-social-accounts.client.controller.js @@ -17,7 +17,7 @@ // Check if there are additional accounts function hasConnectedAdditionalSocialAccounts() { - return ($scope.user.additionalProvidersData && Object.keys($scope.user.additionalProvidersData).length); + return (vm.user.additionalProvidersData && Object.keys(vm.user.additionalProvidersData).length); } // Check if provider is already in use with current user