save and request usernames in lower case for app-user

pull/1/head
Florian Hartwich 2017-06-11 17:12:28 +02:00
parent 9c7298ddc6
commit 5b23a4a9db
1 changed files with 3 additions and 2 deletions

View File

@ -47,7 +47,7 @@ authenticate.route('/')
let authCheck = (username, password, res) => {
const deferred = Q.defer();
AppUserModel.findOne({username: username}).populate('squad').exec((err, user) => {
AppUserModel.findOne({username: username.toLowerCase()}).populate('squad').exec((err, user) => {
if (err) deferred.reject(err.name + ': ' + err.message);
const diff = 7 * 60 * 24; // time till expiration [minutes]
@ -96,7 +96,7 @@ let create = (userParam) => {
// validation
AppUserModel.findOne(
{username: userParam.username},
{username: userParam.username.toLowerCase()},
(err, user) => {
if (err) deferred.reject(err.name + ': ' + err.message);
@ -114,6 +114,7 @@ let create = (userParam) => {
// add hashed password to user object
user.password = bcrypt.hashSync(userParam.password, 10);
user.username = user.username.toLowerCase();
const newUser = new AppUserModel(user);
newUser.save((err, doc) => {