Skip to content

Commit

Permalink
Adding support to use environment variable to filter email inviting (r…
Browse files Browse the repository at this point in the history
  • Loading branch information
davsket authored and rauchg committed Oct 22, 2016
1 parent b75575c commit 1a89db8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/slackin
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -33,6 +34,7 @@ if (!org || !token) {
} else {
flags.org = org
flags.token = token
flags.emails = emails
}

var port = flags.port
Expand Down
13 changes: 13 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function slackin ({
cors: useCors = false,
path='/',
channels,
emails,
silent = false // jshint ignore:line,
}){
// must haves
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1a89db8

Please sign in to comment.