aboutsummaryrefslogtreecommitdiff
path: root/src/api/utils/Util.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/utils/Util.js')
-rw-r--r--src/api/utils/Util.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js
index b8d960d..80bffd5 100644
--- a/src/api/utils/Util.js
+++ b/src/api/utils/Util.js
@@ -206,7 +206,15 @@ class Util {
}
}
- static isAuthorized(req) {
+ static async isAuthorized(req) {
+ if (req.headers.token) {
+ if (!this.options.canApiKey) return false;
+ const user = await db.table('users').where({ apiKey: req.headers.token }).first();
+ if (!user) return false;
+ if (!user.enabled) return false;
+ return true;
+ }
+
if (!req.headers.authorization) return false;
const token = req.headers.authorization.split(' ')[1];
if (!token) return false;