Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces small fix for User Emails #4340

Closed
wants to merge 1 commit into from
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
12 changes: 10 additions & 2 deletions src/RestWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,18 @@ 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. Any space within the string will not pass.
if (!this.data.email.trim().match( /^[^\s@]+@[^\s@]+\.[^\s@]+$/ )) {
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.
if ( _this8.data.email ) {
_this8.data.email = _this8.data.email.split(' ').join('').toLowerCase();
}

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