Trim username
This commit is contained in:
parent
22b536454b
commit
19b660f024
3 changed files with 4 additions and 3 deletions
1
index.js
1
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) => {
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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: []
|
||||
|
|
Loading…
Reference in a new issue