return unauthorized error when api key not found

This commit is contained in:
Eneko Lakasta
2018-02-07 19:12:14 +01:00
parent ea0542dcb1
commit 41f3606572
+6 -1
View File
@@ -73,7 +73,12 @@ AuthApi.prototype.authorizedByAPIKey = function(user, req, callback) {
return callback(err);
}
if ( !isValidApiKey(apikey)) {
return callback(null, false);
const error = new Error('Unauthorized');
error.type = 'auth';
error.subtype = 'api-key-not-found';
error.http_status = 401;
return callback(error);
}
return callback(null, true);