我已通过以下方式实现了启用facebook身份验证的代码:
const authentication = require('feathers-authentication');
const jwt = require('feathers-authentication-jwt');
const local = require('feathers-authentication-local');
const oauth2 = require('feathers-authentication-oauth2');
const GoogleStrategy = require('passport-google-oauth20');
const FacebookStrategy = require('passport-facebook');
module.exports = function () {
const app = this;
const config = app.get('authentication');
app.configure(authentication(config));
app.configure(jwt());
app.configure(local());
app.configure(oauth2(Object.assign({
name: 'google',
Strategy: GoogleStrategy
}, config.google)));
app.configure(oauth2(Object.assign({
name: 'facebook',
Strategy: FacebookStrategy
}, config.facebook)));
app.service('authentication').hooks({
before: {
create: [
authentication.hooks.authenticate(config.strategies),
hook => {
hook.params.payload = hook.params.payload || {}
if(hook.params.user){
Object.assign(hook.params.payload, {email: hook.params.user.email, name: hook.params.user.name});
}
}
],
remove: [
authentication.hooks.authenticate('jwt')
]
}
});
};
如果我在中调试代码执行
node_modules/passport-facebook/lib/strategy.js
有人知道如何将这些值传递给身份验证服务/挂钩以存储它们吗?