Skip to content

Commit dafd8db

Browse files
committed
Lower case user email field
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
1 parent 9ea9c6d commit dafd8db

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: templates/express/config/passport.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ passport.use(new LocalStrategy({
2626
},
2727
function(email, password, done) {
2828
User.findOne({
29-
email: email
29+
email: email.toLowerCase()
3030
}, function(err, user) {
3131
if (err) return done(err);
3232

@@ -45,4 +45,4 @@ passport.use(new LocalStrategy({
4545
}
4646
));
4747

48-
module.exports = passport;
48+
module.exports = passport;

Diff for: templates/express/models/user.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var authTypes = ['github', 'twitter', 'facebook', 'google'];
1111
*/
1212
var UserSchema = new Schema({
1313
name: String,
14-
email: String,
14+
email: { type: String, lowercase: true },
1515
role: {
1616
type: String,
1717
default: 'user'
@@ -153,4 +153,4 @@ UserSchema.methods = {
153153
}
154154
};
155155

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

0 commit comments

Comments
 (0)