From 41f36065723d8b932684309d57ce0b472f04300b Mon Sep 17 00:00:00 2001 From: Eneko Lakasta Date: Wed, 7 Feb 2018 19:12:14 +0100 Subject: [PATCH] return unauthorized error when api key not found --- lib/cartodb/api/auth_api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/api/auth_api.js b/lib/cartodb/api/auth_api.js index 0f31e721..fc490585 100644 --- a/lib/cartodb/api/auth_api.js +++ b/lib/cartodb/api/auth_api.js @@ -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);