diff options
Diffstat (limited to 'src/api/utils')
| -rw-r--r-- | src/api/utils/Util.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js index 905948a..ee4c748 100644 --- a/src/api/utils/Util.js +++ b/src/api/utils/Util.js @@ -175,7 +175,13 @@ class Util { } } - static isAuthorized(req) { + static async isAuthorized(req) { + if (req.headers.token) { + const user = await db.table('users').where({ apiKey: req.headers.token }).first(); + if (!user || !user.enabled) return false; + return user; + } + if (!req.headers.authorization) return false; const token = req.headers.authorization.split(' ')[1]; if (!token) return false; |