From c1dac11a2bb28e4b65ed02595fcb23dbeff4b87a Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 3 Apr 2017 16:11:34 -0600 Subject: [PATCH] Updated docs, hook names --- PLUGINS.md | 9 ++++++--- routes/index.js | 6 +++--- services/passport.js | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/PLUGINS.md b/PLUGINS.md index 819066217..e5cf8d760 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -233,7 +233,7 @@ module.exports = { } ``` -#### Field: `auth` +#### Field: `passport` ```js const FacebookStrategy = require('passport-facebook').Strategy; @@ -241,7 +241,7 @@ const UsersService = require('services/users'); const {ValidateUserLogin, HandleAuthPopupCallback} = require('services/passport'); module.exports = { - auth(passport) { + passport(passport) { passport.use(new FacebookStrategy({ clientID: process.env.TALK_FACEBOOK_APP_ID, clientSecret: process.env.TALK_FACEBOOK_APP_SECRET, @@ -260,7 +260,10 @@ module.exports = { return ValidateUserLogin(profile, user, done); })); }, - routes(router) { + router(router) { + + // Note that we have to import the passport instance here, it is + // instantiated after all the strategies have been mounted. const {passport} = require('services/passport'); /** diff --git a/routes/index.js b/routes/index.js index f6745b1c7..9e38097f9 100644 --- a/routes/index.js +++ b/routes/index.js @@ -25,11 +25,11 @@ if (process.env.NODE_ENV !== 'production') { } // Inject server route plugins. -plugins.get('server', 'routes').forEach(({plugin, routes}) => { - debug(`added plugin '${plugin.name}'`); +plugins.get('server', 'router').forEach((plugin) => { + debug(`added plugin '${plugin.plugin.name}'`); // Pass the root router to the plugin to mount it's routes. - routes(router); + plugin.router(router); }); module.exports = router; diff --git a/services/passport.js b/services/passport.js index 2d6604c3b..09ded01e8 100644 --- a/services/passport.js +++ b/services/passport.js @@ -377,12 +377,12 @@ if (process.env.TALK_FACEBOOK_APP_ID && process.env.TALK_FACEBOOK_APP_SECRET && } // Inject server route plugins. -plugins.get('server', 'auth').forEach(({plugin, auth}) => { - debug(`added plugin '${plugin.name}'`); +plugins.get('server', 'passport').forEach((plugin) => { + debug(`added plugin '${plugin.plugin.name}'`); // Pass the passport.js instance to the plugin to allow it to inject it's // functionality. - auth(passport); + plugin.passport(passport); }); module.exports = {