From e9b5416f931fca3906a88a6125cf73d3139af435 Mon Sep 17 00:00:00 2001 From: David Avellaneda Date: Mon, 3 Oct 2016 07:22:51 -0500 Subject: [PATCH 1/3] Adding support to use environment variable to filter email inviting --- bin/slackin | 2 ++ lib/index.js | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/bin/slackin b/bin/slackin index e09d5329..f6b896b7 100755 --- a/bin/slackin +++ b/bin/slackin @@ -23,6 +23,7 @@ var flags = args.parse(process.argv, { var org = args.sub[0] || process.env.SLACK_SUBDOMAIN var token = args.sub[1] || process.env.SLACK_API_TOKEN +var emails = process.env.EMAIL_SLACK_LIST || '' if (flags.help) { args.showHelp() @@ -33,6 +34,7 @@ if (!org || !token) { } else { flags.org = org flags.token = token + flags.emails = emails } var port = flags.port diff --git a/lib/index.js b/lib/index.js index e4710df3..d970b6b9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -27,6 +27,7 @@ export default function slackin ({ cors: useCors = false, path='/', channels, + emails, silent = false // jshint ignore:line, }){ // must haves @@ -42,6 +43,11 @@ export default function slackin ({ }) } + if (emails) { + // convert to an array + emails = emails.split(',') + } + // setup app let app = express() let srv = http(app) @@ -137,6 +143,13 @@ export default function slackin ({ .json({ msg: 'Invalid email' }) } + // Restricting email invites? + if (emails && emails.indexOf(email) === -1) { + return res + .status(400) + .json({ msg: 'Your email is not on the accepted email list' }) + } + if (coc && '1' != req.body.coc) { return res .status(400) From 3035dc8fd634f79adecd72a136520cfeb72c434d Mon Sep 17 00:00:00 2001 From: David Avellaneda Date: Thu, 26 Jan 2017 17:07:01 -0500 Subject: [PATCH 2/3] Adding documentation about environment variable and how to use it --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 466bc3fc..93055b24 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,21 @@ times 5. If you are not getting invite emails, this might be the reason. Workaround: sign up for a free org, and set up Slackin to point to it (all channels will be visible). +### Restrict invitations using an email list + +You can restrict user invites to a limited list of valid emails. To do it you +only have to export the environment variable `EMAIL_SLACK_LIST` with the email +list (comma separated and spaceless): + +``` +export EMAIL_SLACK_LIST="user@domain.com,pal@company.io,john@doe.co" +``` + +**Important:** By defining the list, any intent to get an invitation with an +email not listed will be rejected with the message: + +> Your email is not on the accepted email list + ### Badges #### Realtime ([demo](https://cldup.com/IaiPnDEAA6.gif)) From 5a11224f6878925512c23755fb60c8147fbce245 Mon Sep 17 00:00:00 2001 From: David Avellaneda Date: Thu, 26 Jan 2017 17:10:18 -0500 Subject: [PATCH 3/3] Removing comma --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93055b24..497c7346 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ list (comma separated and spaceless): export EMAIL_SLACK_LIST="user@domain.com,pal@company.io,john@doe.co" ``` -**Important:** By defining the list, any intent to get an invitation with an +**Important:** By defining the list any intent to get an invitation with an email not listed will be rejected with the message: > Your email is not on the accepted email list