diff --git a/index.js b/index.js index f2925cc..228e8aa 100644 --- a/index.js +++ b/index.js @@ -18,6 +18,7 @@ const db = new PouchDB(config.dbUrl); passport.use('local', new LocalStrategy( (username, password, done) => { + username = username.trim(); db.get(username) .then(doc => { bcrypt.compare(password, doc.password, (err, correct) => { diff --git a/routes/adminSettings/index.js b/routes/adminSettings/index.js index 896c1a7..48a4884 100644 --- a/routes/adminSettings/index.js +++ b/routes/adminSettings/index.js @@ -19,12 +19,12 @@ module.exports = (db) => { bcrypt.hash(req.body.newUserPassword, null, null, async (err, newUserPasswordHash) => { if (err) throw err; await db.put({ - _id: req.body.newUserUsername, + _id: req.body.newUserUsername.trim(), password: newUserPasswordHash, admin: false, wishlist: [] }); - req.flash('success', `Successfully added user ${req.body.newUserUsername}!`); + req.flash('success', `Successfully added user ${req.body.newUserUsername.trim()}!`); res.redirect('/admin-settings'); }); }); diff --git a/routes/setup/index.js b/routes/setup/index.js index bd0f043..9442b77 100644 --- a/routes/setup/index.js +++ b/routes/setup/index.js @@ -22,7 +22,7 @@ module.exports = (db) => { bcrypt.hash(req.body.adminPassword, null, null, (err, adminPasswordHash) => { if (err) throw err; db.put({ - _id: req.body.adminUsername, + _id: req.body.adminUsername.trim(), password: adminPasswordHash, admin: true, wishlist: []