Skip to content

Commit

Permalink
Wiring passport-slack into utility.auth()
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Aug 17, 2017
1 parent e9c93ff commit 520b684
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const path = require("path"),
LocalStrategy = require("passport-local").Strategy,
OAuth2Strategy = require("passport-oauth2").Strategy,
SAMLStrategy = require("passport-saml").Strategy,
SlackStrategy = require("passport-slack").Strategy,
TwitterStrategy = require("passport-twitter").Strategy,
RedisStore = require("connect-redis")(session),
all = "all";
Expand Down Expand Up @@ -503,15 +504,13 @@ function auth (obj, config) {
obj.get("/auth/saml/callback", redirect);
}

// @todo finish!
if (config.auth.slack.enabled) {
passport.use(new FacebookStrategy({
clientID: config.auth.facebook.client_id,
clientSecret: config.auth.facebook.client_secret,
callbackURL: realm + "/auth/facebook/callback"
passport.use(new SlackStrategy({
clientID: config.auth.slack.client_id,
clientSecret: config.auth.slack.client_secret
}, (accessToken, refreshToken, profile, done) => {
delay(() => {
config.auth.facebook.auth(accessToken, refreshToken, profile, (err, user) => {
config.auth.slack.auth(accessToken, refreshToken, profile, (err, user) => {
if (err) {
done(err);
} else {
Expand All @@ -521,11 +520,11 @@ function auth (obj, config) {
});
}));

obj.get("/auth/facebook", middleware.asyncFlag);
obj.get("/auth/facebook", passport.authenticate("facebook"));
obj.get("/auth/facebook/callback", middleware.asyncFlag);
obj.get("/auth/facebook/callback", passport.authenticate("facebook", {failureRedirect: "/login"}));
obj.get("/auth/facebook/callback", redirect);
obj.get("/auth/slack", middleware.asyncFlag);
obj.get("/auth/slack", passport.authenticate("slack"));
obj.get("/auth/slack/callback", middleware.asyncFlag);
obj.get("/auth/slack/callback", passport.authenticate("slack", {failureRedirect: "/login"}));
obj.get("/auth/slack/callback", redirect);
}

if (config.auth.twitter.enabled) {
Expand Down

0 comments on commit 520b684

Please sign in to comment.