Throw error on invalid api key

This commit is contained in:
Jori Lallo
2016-10-05 22:46:17 -07:00
parent 7b7988b7d5
commit 2d741afb20

View File

@@ -50,6 +50,8 @@ export default function auth({ require = true } = {}) {
throw httpErrors.Unauthorized('Invalid api key');
}
if (!apiKey) throw httpErrors.Unauthorized('Invalid token');
user = await User.findOne({
where: { id: apiKey.userId },
});