aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/auth
diff options
context:
space:
mode:
authorPitu <[email protected]>2019-02-19 23:52:24 +0900
committerPitu <[email protected]>2019-02-19 23:52:24 +0900
commit89a271818ed25b0a17a17dd1d6804e34d1f2ec0f (patch)
tree2e63d3b41eeacb8f172f8ee3e1374124b934c6a3 /src/api/routes/auth
parentCreate wizard.js (diff)
downloadhost.fuwn.me-89a271818ed25b0a17a17dd1d6804e34d1f2ec0f.tar.xz
host.fuwn.me-89a271818ed25b0a17a17dd1d6804e34d1f2ec0f.zip
Switch config to .env
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r--src/api/routes/auth/changePasswordPOST.js4
-rw-r--r--src/api/routes/auth/registerPOST.js6
2 files changed, 3 insertions, 7 deletions
diff --git a/src/api/routes/auth/changePasswordPOST.js b/src/api/routes/auth/changePasswordPOST.js
index bd64320..d698896 100644
--- a/src/api/routes/auth/changePasswordPOST.js
+++ b/src/api/routes/auth/changePasswordPOST.js
@@ -1,7 +1,5 @@
const Route = require('../../structures/Route');
-const config = require('../../../../config');
const log = require('../../utils/Log');
-const db = require('knex')(config.server.database);
const bcrypt = require('bcrypt');
const moment = require('moment');
@@ -10,7 +8,7 @@ class changePasswordPOST extends Route {
super('/auth/password/change', 'post');
}
- async run(req, res, user) {
+ async run(req, res, db, user) {
if (!req.body) return res.status(400).json({ message: 'No body provided' });
const { password, newPassword } = req.body;
if (!password || !newPassword) return res.status(401).json({ message: 'Invalid body provided' });
diff --git a/src/api/routes/auth/registerPOST.js b/src/api/routes/auth/registerPOST.js
index d3532f4..762eaf2 100644
--- a/src/api/routes/auth/registerPOST.js
+++ b/src/api/routes/auth/registerPOST.js
@@ -1,7 +1,5 @@
const Route = require('../../structures/Route');
-const config = require('../../../../config');
const log = require('../../utils/Log');
-const db = require('knex')(config.server.database);
const bcrypt = require('bcrypt');
const randomstring = require('randomstring');
const moment = require('moment');
@@ -11,8 +9,8 @@ class registerPOST extends Route {
super('/auth/register', 'post', { bypassAuth: true });
}
- async run(req, res) {
- if (!config.enableCreateUserAccounts) return res.status(401).json({ message: 'Creation of new accounts is currently disabled' });
+ async run(req, res, db) {
+ if (!process.env.USER_ACCOUNTS) return res.status(401).json({ message: 'Creation of new accounts is currently disabled' });
if (!req.body) return res.status(400).json({ message: 'No body provided' });
const { username, password } = req.body;
if (!username || !password) return res.status(401).json({ message: 'Invalid body provided' });