Skip to content

Commit

Permalink
Lower case user email field
Browse files Browse the repository at this point in the history
Lower case the user email field in when passport queries to find a user
during login. Also lowercase the email on user creations. Fix #177
  • Loading branch information
samhug committed Apr 14, 2014
1 parent 9ea9c6d commit dafd8db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions templates/express/config/passport.js
Expand Up @@ -26,7 +26,7 @@ passport.use(new LocalStrategy({
},
function(email, password, done) {
User.findOne({
email: email
email: email.toLowerCase()
}, function(err, user) {
if (err) return done(err);

Expand All @@ -45,4 +45,4 @@ passport.use(new LocalStrategy({
}
));

module.exports = passport;
module.exports = passport;
4 changes: 2 additions & 2 deletions templates/express/models/user.js
Expand Up @@ -11,7 +11,7 @@ var authTypes = ['github', 'twitter', 'facebook', 'google'];
*/
var UserSchema = new Schema({
name: String,
email: String,
email: { type: String, lowercase: true },
role: {
type: String,
default: 'user'
Expand Down Expand Up @@ -153,4 +153,4 @@ UserSchema.methods = {
}
};

module.exports = mongoose.model('User', UserSchema);
module.exports = mongoose.model('User', UserSchema);

0 comments on commit dafd8db

Please sign in to comment.