diff options
Diffstat (limited to 'controllers/authController.js')
| -rw-r--r-- | controllers/authController.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/controllers/authController.js b/controllers/authController.js index 95a151e..eb7df09 100644 --- a/controllers/authController.js +++ b/controllers/authController.js @@ -15,6 +15,10 @@ authController.verify = async (req, res, next) => { const user = await db.table('users').where('username', username).first(); if (!user) return res.json({ success: false, description: 'Username doesn\'t exist' }); + if (user.enabled === false || user.enabled === 0) return res.json({ + success: false, + description: 'This account has been disabled' + }); bcrypt.compare(password, user.password, (err, result) => { if (err) { @@ -38,10 +42,10 @@ authController.register = async (req, res, next) => { if (password === undefined) return res.json({ success: false, description: 'No password provided' }); if (username.length < 4 || username.length > 32) { - return res.json({ success: false, description: 'Username must have 4-32 characters' }) + return res.json({ success: false, description: 'Username must have 4-32 characters' }); } if (password.length < 6 || password.length > 64) { - return res.json({ success: false, description: 'Password must have 6-64 characters' }) + return res.json({ success: false, description: 'Password must have 6-64 characters' }); } const user = await db.table('users').where('username', username).first(); @@ -56,9 +60,10 @@ authController.register = async (req, res, next) => { await db.table('users').insert({ username: username, password: hash, - token: token + token: token, + enabled: 1 }); - return res.json({ success: true, token: token }) + return res.json({ success: true, token: token }); }); }; |