Permalink
Browse files

Adding support to use environment variable to filter email inviting (#…

  • Loading branch information...
1 parent b75575c commit 1a89db8a88701c0407f2296c3ddaae72c920f053 @davsket davsket committed with Oct 22, 2016
Showing with 15 additions and 0 deletions.
  1. +2 −0 bin/slackin
  2. +13 −0 lib/index.js
View
@@ -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
View
@@ -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)

0 comments on commit 1a89db8

Please sign in to comment.