-
+
diff --git a/modules/users/server/config/strategies/local.js b/modules/users/server/config/strategies/local.js
index 684e7a8582..a72510f496 100644
--- a/modules/users/server/config/strategies/local.js
+++ b/modules/users/server/config/strategies/local.js
@@ -15,7 +15,7 @@ module.exports = function () {
},
function (username, password, done) {
User.findOne({
- username: username
+ username: username.toLowerCase()
}, function (err, user) {
if (err) {
return done(err);
diff --git a/modules/users/server/controllers/users/users.password.server.controller.js b/modules/users/server/controllers/users/users.password.server.controller.js
index d59c73975a..aa51169403 100644
--- a/modules/users/server/controllers/users/users.password.server.controller.js
+++ b/modules/users/server/controllers/users/users.password.server.controller.js
@@ -30,7 +30,7 @@ exports.forgot = function (req, res, next) {
function (token, done) {
if (req.body.username) {
User.findOne({
- username: req.body.username
+ username: req.body.username.toLowerCase()
}, '-salt -password', function (err, user) {
if (!user) {
return res.status(400).send({
@@ -144,7 +144,10 @@ exports.reset = function (req, res, next) {
if (err) {
res.status(400).send(err);
} else {
- // Return authenticated user
+ // Remove sensitive data before return authenticated user
+ user.password = undefined;
+ user.salt = undefined;
+
res.json(user);
done(err, user);
diff --git a/modules/users/server/models/user.server.model.js b/modules/users/server/models/user.server.model.js
index e7c0af0861..87fd11d9d2 100644
--- a/modules/users/server/models/user.server.model.js
+++ b/modules/users/server/models/user.server.model.js
@@ -51,8 +51,9 @@ var UserSchema = new Schema({
},
email: {
type: String,
- trim: true,
unique: true,
+ lowercase: true,
+ trim: true,
default: '',
validate: [validateLocalStrategyEmail, 'Please fill a valid email address']
},
@@ -60,6 +61,7 @@ var UserSchema = new Schema({
type: String,
unique: 'Username already exists',
required: 'Please fill in a username',
+ lowercase: true,
trim: true
},
password: {
@@ -139,7 +141,7 @@ UserSchema.methods.authenticate = function (password) {
*/
UserSchema.statics.findUniqueUsername = function (username, suffix, callback) {
var _this = this;
- var possibleUsername = username + (suffix || '');
+ var possibleUsername = username.toLowerCase() + (suffix || '');
_this.findOne({
username: possibleUsername