Skip to content

Commit

Permalink
Redirect signed up users to Slack
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Dec 16, 2015
1 parent 9817875 commit e0d78f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ function invite(channel, coc, email, fn){
email: email
})
.end(function(res){
if (res.body.redirectUrl) {
var err = new Error(res.body.msg || 'Server error');
window.setTimeout(() => {
location.href = res.body.redirectUrl;
}, 1500);
}
if (res.error) {
var err = new Error(res.body.msg || 'Server error');
return fn(err);
Expand Down
6 changes: 6 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ export default function slackin({

invite({ token, org, email, channel: chanId }, err => {
if (err) {
if (err.redirectUrl) {
return res
.status(303)
.json({ msg: err.message, redirectUrl: `https://${org}.slack.com` });
}

return res
.status(400)
.json({ msg: err.message });
Expand Down
2 changes: 1 addition & 1 deletion lib/slack-invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function invite({ org, token, email, channel }, fn){
} else if (providedError === 'already_invited') {
fn(new Error('You have already been invited to slack. Check for an email from feedback@slack.com.'));
} else if (providedError === 'already_in_team') {
fn(new Error(`Already invited. Sign in at https://${org}.slack.com.`));
fn(new Error(`Already invited. Sending you to https://${org}.slack.com...`));
} else {
fn(new Error(providedError));
}
Expand Down

0 comments on commit e0d78f3

Please sign in to comment.