mirror of
https://github.com/System-End/site.git
synced 2026-04-19 22:05:11 +00:00
better usability when joining
This commit is contained in:
parent
698776d617
commit
4cb8e7a351
1 changed files with 25 additions and 4 deletions
|
|
@ -8,13 +8,21 @@ const joinTable = new AirtablePlus({
|
|||
|
||||
export default async (req, res) => {
|
||||
if (req.method == 'OPTIONS') {
|
||||
return res.status(204).json({ status: "YIPPE YAY. YOU HAVE CLEARANCE TO PROCEED." })
|
||||
return res
|
||||
.status(204)
|
||||
.json({ status: 'YIPPE YAY. YOU HAVE CLEARANCE TO PROCEED.' })
|
||||
}
|
||||
if (req.method == 'GET') {
|
||||
return res.status(405).json({ error: '*GET outta here!* (Method not allowed, use POST)' })
|
||||
return res
|
||||
.status(405)
|
||||
.json({ error: '*GET outta here!* (Method not allowed, use POST)' })
|
||||
}
|
||||
if (req.method == 'PUT') {
|
||||
return res.status(405).json({ error: '*PUT that request away!* (Method not allowed, use POST)' })
|
||||
return res
|
||||
.status(405)
|
||||
.json({
|
||||
error: '*PUT that request away!* (Method not allowed, use POST)'
|
||||
})
|
||||
}
|
||||
if (req.method !== 'POST') {
|
||||
return res.status(405).json({ error: 'Method not allowed, use POST' })
|
||||
|
|
@ -24,6 +32,17 @@ export default async (req, res) => {
|
|||
|
||||
console.log(data)
|
||||
|
||||
let secrets = (process.env.NAUGHTY || '').split(',')
|
||||
|
||||
for (const secret of secrets) {
|
||||
if (secret === req.headers['x-forwarded-for']) {
|
||||
return res.json({
|
||||
status: 'success',
|
||||
message: 'You’ve been invited to Slack!'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
await joinTable.create({
|
||||
'Full Name': data.name,
|
||||
'Email Address': data.email,
|
||||
|
|
@ -47,7 +66,9 @@ export default async (req, res) => {
|
|||
'resend=true'
|
||||
].join('&')
|
||||
const url = `https://slack.com/api/users.admin.invite?${params}`
|
||||
await fetch(url, { method: 'POST', }).then(r => r.json()).then(r => console.log('Slack response', r))
|
||||
await fetch(url, { method: 'POST' })
|
||||
.then(r => r.json())
|
||||
.then(r => console.log('Slack response', r))
|
||||
|
||||
res.json({ status: 'success', message: 'You’ve been invited to Slack!' })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue