diff options
| author | Pitu <[email protected]> | 2021-06-15 00:12:26 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2021-06-15 00:12:26 +0900 |
| commit | d3c80127ecdc83cffb9ba9a05f47452fec60287c (patch) | |
| tree | fb056e08947393a6487238b247703565f049a149 /src/api/routes/auth | |
| parent | chore: get host from req instead of config (diff) | |
| download | host.fuwn.me-d3c80127ecdc83cffb9ba9a05f47452fec60287c.tar.xz host.fuwn.me-d3c80127ecdc83cffb9ba9a05f47452fec60287c.zip | |
chore: update process.env usage
Diffstat (limited to 'src/api/routes/auth')
| -rw-r--r-- | src/api/routes/auth/loginPOST.js | 3 | ||||
| -rw-r--r-- | src/api/routes/auth/registerPOST.js | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/api/routes/auth/loginPOST.js b/src/api/routes/auth/loginPOST.js index 373252b..cc72145 100644 --- a/src/api/routes/auth/loginPOST.js +++ b/src/api/routes/auth/loginPOST.js @@ -2,6 +2,7 @@ const bcrypt = require('bcrypt'); const moment = require('moment'); const JWT = require('jsonwebtoken'); const Route = require('../../structures/Route'); +const Util = require('../../utils/Util'); class loginPOST extends Route { constructor() { @@ -37,7 +38,7 @@ class loginPOST extends Route { iss: 'chibisafe', sub: user.id, iat: moment.utc().valueOf() - }, process.env.SECRET, { expiresIn: '30d' }); + }, Util.config.secret, { expiresIn: '30d' }); return res.json({ message: 'Successfully logged in.', diff --git a/src/api/routes/auth/registerPOST.js b/src/api/routes/auth/registerPOST.js index 7b9eb3c..e740c83 100644 --- a/src/api/routes/auth/registerPOST.js +++ b/src/api/routes/auth/registerPOST.js @@ -12,7 +12,7 @@ class registerPOST extends Route { async run(req, res, db) { // Only allow admins to create new accounts if the sign up is deactivated const user = await Util.isAuthorized(req); - if ((!user || !user.isAdmin) && process.env.USER_ACCOUNTS === 'false') return res.status(401).json({ message: 'Creation of new accounts is currently disabled' }); + if ((!user || !user.isAdmin) && !Util.config.userAccounts) 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; |