save and request usernames in lower case for app-user
parent
9c7298ddc6
commit
5b23a4a9db
|
@ -47,7 +47,7 @@ authenticate.route('/')
|
||||||
let authCheck = (username, password, res) => {
|
let authCheck = (username, password, res) => {
|
||||||
const deferred = Q.defer();
|
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);
|
if (err) deferred.reject(err.name + ': ' + err.message);
|
||||||
|
|
||||||
const diff = 7 * 60 * 24; // time till expiration [minutes]
|
const diff = 7 * 60 * 24; // time till expiration [minutes]
|
||||||
|
@ -96,7 +96,7 @@ let create = (userParam) => {
|
||||||
|
|
||||||
// validation
|
// validation
|
||||||
AppUserModel.findOne(
|
AppUserModel.findOne(
|
||||||
{username: userParam.username},
|
{username: userParam.username.toLowerCase()},
|
||||||
(err, user) => {
|
(err, user) => {
|
||||||
if (err) deferred.reject(err.name + ': ' + err.message);
|
if (err) deferred.reject(err.name + ': ' + err.message);
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ let create = (userParam) => {
|
||||||
|
|
||||||
// add hashed password to user object
|
// add hashed password to user object
|
||||||
user.password = bcrypt.hashSync(userParam.password, 10);
|
user.password = bcrypt.hashSync(userParam.password, 10);
|
||||||
|
user.username = user.username.toLowerCase();
|
||||||
|
|
||||||
const newUser = new AppUserModel(user);
|
const newUser = new AppUserModel(user);
|
||||||
newUser.save((err, doc) => {
|
newUser.save((err, doc) => {
|
||||||
|
|
Loading…
Reference in New Issue