Skip to content
Closed
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
10 changes: 8 additions & 2 deletions src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,16 @@ RestWrite.prototype._validateEmail = function() {
if (!this.data.email || this.data.email.__op === 'Delete') {
return Promise.resolve();
}
// Validate basic email address format
if (!this.data.email.match(/^.+@.+$/)) {

// Validate basic email address format.
// Will strip spaces surrounding the string. If any space within the string, will not pass.
if (!this.data.email.trim().match( /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/ )) {
return Promise.reject(new Parse.Error(Parse.Error.INVALID_EMAIL_ADDRESS, 'Email address format is invalid.'));
}

//Fixes issues where emails might be duplicated because of a space ' ' or case sensitivity.
this.data.email = this.data.email.split(' ').join('').toLowerCase();

// Same problem for email as above for username
return this.config.database.find(
this.className,
Expand Down