mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-07 22:57:48 +02:00
Use validator.js for email validation
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -43,14 +43,15 @@
|
||||
"passport": "~0.2.2",
|
||||
"passport-facebook": "^2.0.0",
|
||||
"passport-github": "~0.1.5",
|
||||
"passport-paypal-openidconnect": "^0.1.1",
|
||||
"passport-google-oauth": "~0.2.0",
|
||||
"passport-linkedin": "~0.1.3",
|
||||
"passport-local": "^1.0.0",
|
||||
"passport-paypal-openidconnect": "^0.1.1",
|
||||
"passport-twitter": "^1.0.2",
|
||||
"serve-favicon": "^2.3.0",
|
||||
"socket.io": "^1.3.5",
|
||||
"swig": "^1.4.2"
|
||||
"swig": "^1.4.2",
|
||||
"validator": "^3.41.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt-concurrent": "^2.0.0",
|
||||
|
||||
Reference in New Issue
Block a user