Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

supporting valid email (i.e. root@admin) #940

Merged
merged 1 commit into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/users/server/models/user.server.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var validateLocalStrategyProperty = function (property) {
* A Validation function for local strategy email
*/
var validateLocalStrategyEmail = function (email) {
return ((this.provider !== 'local' && !this.updated) || validator.isEmail(email));
return ((this.provider !== 'local' && !this.updated) || validator.isEmail(email, { require_tld: false }));
};

/**
Expand Down Expand Up @@ -177,7 +177,7 @@ UserSchema.statics.generateRandomPassphrase = function () {
var password = '';
var repeatingCharacters = new RegExp('(.)\\1{2,}', 'g');

// iterate until the we have a valid passphrase.
// iterate until the we have a valid passphrase.
// NOTE: Should rarely iterate more than once, but we need this to ensure no repeating characters are present.
while (password.length < 20 || repeatingCharacters.test(password)) {
// build the random password
Expand Down
29 changes: 24 additions & 5 deletions modules/users/tests/server/user.server.model.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('User Model Unit Tests:', function () {
});
});

it('should not allow a less than 10 characters long - "P@$$w0rd!"', function (done) {
it('should not allow a password less than 10 characters long - "P@$$w0rd!"', function (done) {
var _user1 = new User(user1);
_user1.password = 'P@$$w0rd!';

Expand All @@ -273,7 +273,7 @@ describe('User Model Unit Tests:', function () {
});
});

it('should not allow a greater than 128 characters long.', function (done) {
it('should not allow a password greater than 128 characters long.', function (done) {
var _user1 = new User(user1);
_user1.password = ')!/uLT="lh&:`6X!]|15o!$!TJf,.13l?vG].-j],lFPe/QhwN#{Z<[*1nX@n1^?WW-%_.*D)m$toB+N7z}kcN#B_d(f41h%w@0F!]igtSQ1gl~6sEV&r~}~1ub>If1c+';

Expand All @@ -283,7 +283,7 @@ describe('User Model Unit Tests:', function () {
});
});

it('should not allow more than 3 or more repeating characters - "P@$$w0rd!!!"', function (done) {
it('should not allow a password with 3 or more repeating characters - "P@$$w0rd!!!"', function (done) {
var _user1 = new User(user1);
_user1.password = 'P@$$w0rd!!!';

Expand Down Expand Up @@ -344,10 +344,10 @@ describe('User Model Unit Tests:', function () {

});

it('should not allow invalid email address - "123@123"', function (done) {
it('should not allow invalid email address - "123@123@123"', function (done) {
var _user1 = new User(user1);

_user1.email = '123@123';
_user1.email = '123@123@123';
_user1.save(function (err) {
if (!err) {
_user1.remove(function (err_remove) {
Expand All @@ -363,6 +363,25 @@ describe('User Model Unit Tests:', function () {

});

it('should allow email address - "123@123"', function (done) {
var _user1 = new User(user1);

_user1.email = '123@123';
_user1.save(function (err) {
if (!err) {
_user1.remove(function (err_remove) {
should.not.exist(err);
should.not.exist(err_remove);
done();
});
} else {
should.not.exist(err);
done();
}
});

});

it('should not allow invalid email address - "123.com"', function (done) {
var _user1 = new User(user1);

Expand Down