Skip to content

Commit

Permalink
[feat] Remove pushError method not useful for now
Browse files Browse the repository at this point in the history
  • Loading branch information
seblucas committed Dec 16, 2018
1 parent 4dd5e86 commit 2a2768d
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,3 @@ exports.monitor = functions.https.onRequest((req, res) => {
res.sendStatus(500);
});
});

exports.pushError = functions.https.onRequest((req, res) => {
if (!req.headers.authorization) {
console.error('No authorization token provided');
res.status(403).send('Unauthorized');
return;
}
if (req.method !== 'POST') {
res.status(400).send('Only POST is allowed');
return;
}

let idToken = req.headers.authorization;
admin.database().ref('/users/').orderByChild('key').equalTo(idToken).once('value')
.then(newValue => {
if (!newValue.val()) {
console.error('Authorization token not found :');
res.status(403).send('Unauthorized');
}
if (!req.body.hasOwnProperty('time') || !req.body.hasOwnProperty('message')) {
console.error('Bad data in payload :', req.body);
res.status(422).send('Bad data');
}
console.log('Authentication OK', req.body);
var newPostRef = admin.database().ref('/errors/').push(req.body);
res.status(200).json(newPostRef.key);
})
.catch(error => {
console.error('Error while verifying authorization token :', error);
res.status(403).send('Unauthorized');
});
});

0 comments on commit 2a2768d

Please sign in to comment.