Skip to content

Commit

Permalink
refactor(regex): removal #129
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Jan 30, 2019
1 parent febcbdf commit 10a08de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var userSchema = mongoose.Schema({
username: { type: String, required: true, unique: true },
password: { type: String, required: true, select: false },
fullname: { type: String, required: true, index: true },
email: { type: String, required: true, unique: true },
email: { type: String, required: true, unique: true, lowercase: true },
role: { type: String, required: true },
lastOnline: Date,
title: String,
Expand Down Expand Up @@ -341,7 +341,7 @@ userSchema.statics.getUserByEmail = function (email, callback) {
return callback('Invalid Email - UserSchema.GetUserByEmail()', null)
}

return this.model(COLLECTION).findOne({ email: new RegExp('^' + email + '$', 'i') }, callback)
return this.model(COLLECTION).findOne({ email: email.toLowerCase() }, callback)
}

/**
Expand Down

0 comments on commit 10a08de

Please sign in to comment.