Return unauth

This commit is contained in:
vjrj 2018-06-12 06:08:25 +02:00
parent 3e5700f648
commit eefa586007

View file

@ -65,7 +65,7 @@ Meteor.startup(() => {
} }
}); });
// Maps to: /api/v1/status/last-fire-detected // Maps to: /api/v1/status/last-fires-count
apiV1.addRoute('status/active-fires-count', { authRequired: false }, { apiV1.addRoute('status/active-fires-count', { authRequired: false }, {
get: function get() { get: function get() {
return { total: ActiveFiresCollection.find({}).count() }; return { total: ActiveFiresCollection.find({}).count() };
@ -80,7 +80,8 @@ Meteor.startup(() => {
}); });
// Maps to: /api/v1/fires-in/:lat/:lng/:km // Maps to: /api/v1/fires-in/:lat/:lng/:km
// Ex: http://127.0.0.1:3000/api/v1/fires-in/38.736946/-9.142685/100 // 100 km max
// Ex: http://127.0.0.1:3000/api/v1/fires-in/token/38.736946/-9.142685/100
apiV1.addRoute('fires-in/:token/:lat/:lng/:km', { authRequired: false }, { apiV1.addRoute('fires-in/:token/:lat/:lng/:km', { authRequired: false }, {
get: function get() { get: function get() {
const lat = Number(this.urlParams.lat); const lat = Number(this.urlParams.lat);
@ -94,7 +95,7 @@ Meteor.startup(() => {
if (token !== Meteor.settings.private.internalApiToken) { if (token !== Meteor.settings.private.internalApiToken) {
console.warn(`WARNING: Query for fires in ${lat}, ${lng} in ${km} km radius with wrong token`); console.warn(`WARNING: Query for fires in ${lat}, ${lng} in ${km} km radius with wrong token`);
return {}; return { error: 'Unauthorized' };
} }
console.log(`Query for fires in ${lat}, ${lng} in ${km} km radius`); console.log(`Query for fires in ${lat}, ${lng} in ${km} km radius`);