Skip to content
Snippets Groups Projects
Commit 722b75df authored by Erick Hitter's avatar Erick Hitter
Browse files

Limit the users who can trigger a command

parent 136e13c7
No related branches found
No related tags found
1 merge request!5Limit to a given user, and improve feedback
This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
{ {
"command_user" : "",
"wp_endpoint" : "", "wp_endpoint" : "",
"wp_username" : "", "wp_username" : "",
"wp_password" : "", "wp_password" : "",
......
...@@ -31,6 +31,16 @@ app.post( '/log', function( req, res ) { ...@@ -31,6 +31,16 @@ app.post( '/log', function( req, res ) {
return res.sendStatus( 400 ); return res.sendStatus( 400 );
} }
// Limit who can trigger the command
if ( 'undefined' === typeof req.body.user_name || config.command_user !== req.body.user_name ) {
var response = {
"response_type": "ephemeral",
"text": "Sorry, you can't record completed tasks."
};
return res.send( response );
}
// Massage the title // Massage the title
var title = req.body.text; var title = req.body.text;
title = striptags( title, [] ); title = striptags( title, [] );
...@@ -58,7 +68,7 @@ app.post( '/log', function( req, res ) { ...@@ -58,7 +68,7 @@ app.post( '/log', function( req, res ) {
"text": "**Entry recorded (**ID #" + resp.id + ", <" + resp.link + ">**)**\n" + resp.title.rendered "text": "**Entry recorded (**ID #" + resp.id + ", <" + resp.link + ">**)**\n" + resp.title.rendered
}; };
res.send( response); res.send( response );
} ); } );
} ); } );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment