aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/auth
diff options
context:
space:
mode:
authorKana <[email protected]>2021-06-19 02:03:57 +0900
committerGitHub <[email protected]>2021-06-19 02:03:57 +0900
commit065c5221a0250838f1d1f9bb7a7922ff4f55e038 (patch)
tree8a69a81f00e6bff2752f4f7c59dcbbf21f893b20 /src/api/routes/auth
parentchore: docs update (diff)
parentfix: potentially fix the blocked extensions array splitting (diff)
downloadhost.fuwn.me-065c5221a0250838f1d1f9bb7a7922ff4f55e038.tar.xz
host.fuwn.me-065c5221a0250838f1d1f9bb7a7922ff4f55e038.zip
Merge pull request #278 from Zephyrrus/Zephyrrus-feature/database_based_settings
Zephyrrus feature/database based settings
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r--src/api/routes/auth/loginPOST.js3
-rw-r--r--src/api/routes/auth/registerPOST.js2
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;