Merge remote-tracking branch 'origin/as-validate-email-length'

GitOrigin-RevId: 00f46c637a7563443e903f491ec39446dc570b5f
This commit is contained in:
Douglas Lovell 2019-01-29 17:14:59 -03:00 committed by sharelatex
parent 9a0dd31d8c
commit dc60d6b630
2 changed files with 6 additions and 2 deletions

View file

@ -4,6 +4,7 @@ module.exports = EmailHelper =
parseEmail: (email) -> parseEmail: (email) ->
return null unless email? return null unless email?
return null if email.length > 254
email = email.trim().toLowerCase() email = email.trim().toLowerCase()
matched = email.match EMAIL_REGEXP matched = email.match EMAIL_REGEXP

View file

@ -6,10 +6,13 @@ uuid = require('uuid')
Schema = mongoose.Schema Schema = mongoose.Schema
ObjectId = Schema.ObjectId ObjectId = Schema.ObjectId
# See https://stackoverflow.com/questions/386294/what-is-the-maximum-length-of-a-valid-email-address/574698#574698
MAX_EMAIL_LENGTH = 254
UserSchema = new Schema UserSchema = new Schema
email : {type : String, default : ''} email : {type : String, default : '', maxlength: MAX_EMAIL_LENGTH }
emails: [{ emails: [{
email: { type : String, default : '' }, email: { type : String, default : '', maxlength: MAX_EMAIL_LENGTH },
reversedHostname: { type : String, default : '' }, reversedHostname: { type : String, default : '' },
createdAt: { type : Date, default: () -> new Date() }, createdAt: { type : Date, default: () -> new Date() },
confirmedAt: { type: Date } confirmedAt: { type: Date }